diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-08-18 11:15:50 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-08-18 11:15:50 +0200 |
commit | c30bbdb0fa50cedc56eec71feeadc969ba5a3edf (patch) | |
tree | 6935b4d042618900ee0f7fd291c14ed55ae06cf8 /processing/src/main/java/com | |
parent | 529694a88d48270298171fdcb87d1439f183202b (diff) |
Skip logging only for IllegalInputException
- Add IllegalInputException to signal cases where we know the exception
is caused by illegal input received from the requestor.
- Only skip logging for IllegalInputException instead of the superclass
IllegalArgumentException as that is also used to signal illegal
arguments to methods due to bugs which are otherwise hard to debug.
- Throw IllegalInputException rather than IllegalArgumentException
where appropriate.
- Deprecated QueryException as it was only used to be able to separate
between query string and query parameter exceptions, and not doing
that consistently, and is in a package we don't want more use of.
- Clean up some cases where the wrong exception was thrown.
Diffstat (limited to 'processing/src/main/java/com')
3 files changed, 38 insertions, 32 deletions
diff --git a/processing/src/main/java/com/yahoo/processing/IllegalInputException.java b/processing/src/main/java/com/yahoo/processing/IllegalInputException.java new file mode 100644 index 00000000000..3f1605860ed --- /dev/null +++ b/processing/src/main/java/com/yahoo/processing/IllegalInputException.java @@ -0,0 +1,25 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.processing; + +/** + * Thrown on illegal input received from the requesting client. + * Use this instead of the superclass, IllegalArgumentException + * to signal illegal input to the client without causing logging and stack traces, + * + * @author bratseth + */ +public class IllegalInputException extends IllegalArgumentException { + + public IllegalInputException(String message) { + super(message); + } + + public IllegalInputException(Throwable cause) { + super(cause); + } + + public IllegalInputException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/processing/src/main/java/com/yahoo/processing/request/CloneHelper.java b/processing/src/main/java/com/yahoo/processing/request/CloneHelper.java index 93b7f88f5a7..837ff3db295 100644 --- a/processing/src/main/java/com/yahoo/processing/request/CloneHelper.java +++ b/processing/src/main/java/com/yahoo/processing/request/CloneHelper.java @@ -84,11 +84,11 @@ public class CloneHelper { if (object instanceof FreezableClass) return ((FreezableClass)object).clone(); else if (object instanceof PublicCloneable) - return ((PublicCloneable)object).clone(); + return ((PublicCloneable<?>)object).clone(); else if (object instanceof LinkedList) - return ((LinkedList) object).clone(); + return ((LinkedList<?>) object).clone(); else if (object instanceof ArrayList) - return ((ArrayList) object).clone(); + return ((ArrayList<?>) object).clone(); try { Method cloneMethod = cloneMethodCache.get(object); diff --git a/processing/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java b/processing/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java index 60e60796afe..c436f92f78b 100644 --- a/processing/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java +++ b/processing/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.response; -import com.google.common.util.concurrent.ExecutionList; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import com.yahoo.collections.Tuple2; @@ -26,14 +25,10 @@ public class DefaultIncomingData<DATATYPE extends Data> implements IncomingData< private List<Tuple2<Runnable,Executor>> newDataListeners = null; - /** - * If this is completed no more data can be added - */ + /** Whether this is completed, such that no more data can be added */ private boolean complete = false; - /** - * Creates an instance which must be assigned an owner after creation - */ + /** Creates an instance which must be assigned an owner after creation */ public DefaultIncomingData() { this(null); } @@ -43,9 +38,7 @@ public class DefaultIncomingData<DATATYPE extends Data> implements IncomingData< completionFuture = SettableFuture.create(); } - /** - * Assigns the owner of this. Throws an exception if the owner is already set. - */ + /** Assigns the owner of this. Throws an exception if the owner is already set. */ public final void assignOwner(DataList<DATATYPE> owner) { if (this.owner != null) throw new NullPointerException("Owner of " + this + " was already assigned"); this.owner = owner; @@ -61,42 +54,32 @@ public class DefaultIncomingData<DATATYPE extends Data> implements IncomingData< return completionFuture; } - /** - * Returns whether the data in this is complete - */ + /** Returns whether the data in this is complete */ @Override public synchronized boolean isComplete() { return complete; } - /** - * Add new data and mark this as completed - */ + /** Adds new data and marks this as completed */ @Override public synchronized void addLast(DATATYPE data) { addLast(Collections.singletonList(data)); } - /** - * Add new data without completing this - */ + /** Adds new data without completing this */ @Override public synchronized void add(DATATYPE data) { add(Collections.singletonList(data)); } - /** - * Add new data and mark this as completed - */ + /** Adds new data and marks this as completed */ @Override public synchronized void addLast(List<DATATYPE> data) { add(data); markComplete(); } - /** - * Add new data without completing this - */ + /** Adds new data without completing this */ @Override public synchronized void add(List<DATATYPE> data) { if (complete) throw new IllegalStateException("Attempted to add data to completed " + this); @@ -105,9 +88,7 @@ public class DefaultIncomingData<DATATYPE extends Data> implements IncomingData< notifyDataListeners(); } - /** - * Mark this as completed and notify any listeners - */ + /** Marks this as completed and notify any listeners */ @Override public synchronized void markComplete() { complete = true; @@ -115,7 +96,7 @@ public class DefaultIncomingData<DATATYPE extends Data> implements IncomingData< } /** - * Get and remove all the data currently available in this. + * Gets and removes all the data currently available in this. * The returned list is a modifiable fresh instance owned by the caller. */ public synchronized List<DATATYPE> drain() { |