From e5e0dd5c2a2dcb9622d11d811d58a97495feb3df Mon Sep 17 00:00:00 2001 From: Sudheesh Katkam Date: Thu, 20 Aug 2015 11:13:25 -0700 Subject: [PATCH] DRILL-3583: Deprecate UserException#build method to avoid mishaps --- .../drill/common/exceptions/UserException.java | 13 +++++++++++++ .../exec/expr/fn/impl/AggregateErrorFunctions.java | 9 ++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java index b943710a676..b006fe33e54 100644 --- a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java +++ b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java @@ -38,6 +38,7 @@ * @see org.apache.drill.exec.proto.UserBitShared.DrillPBError.ErrorType */ public class UserException extends DrillRuntimeException { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(UserException.class); public static final String MEMORY_ERROR_MSG = "One or more nodes ran out of memory while executing the query."; @@ -534,6 +535,18 @@ public UserException build(final Logger logger) { return newException; } + + /** + * Builds a user exception or returns the wrapped one. + * + * @return user exception + * @deprecated Use {@link #build(Logger)} instead. If the error is a system error, the error message is logged to + * this {@link UserException#logger}. + */ + @Deprecated + public UserException build() { + return build(logger); + } } private final DrillPBError.ErrorType errorType; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java index 0a9ef8d6e9b..3c270a0f544 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/AggregateErrorFunctions.java @@ -34,7 +34,6 @@ * to perform function resolution. Otherwise with implicit cast we will try to bind to an existing function. */ public class AggregateErrorFunctions { - private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AggregateErrorFunctions.class); @FunctionTemplate(names = {"sum", "max", "avg", "stddev_pop", "stddev_samp", "stddev", "var_pop", "var_samp", "variance"}, scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE) @@ -48,7 +47,7 @@ public void setup() { if (true) { throw org.apache.drill.common.exceptions.UserException.unsupportedError() .message("Only COUNT aggregate function supported for Boolean type") - .build(logger); + .build(); } } @@ -78,7 +77,7 @@ public void setup() { if (true) { throw org.apache.drill.common.exceptions.UserException.unsupportedError() .message("Only COUNT aggregate function supported for Boolean type") - .build(logger); + .build(); } } @@ -108,7 +107,7 @@ public void setup() { if (true) { throw org.apache.drill.common.exceptions.UserException.unsupportedError() .message("Only COUNT, MIN and MAX aggregate functions supported for VarChar type") - .build(logger); + .build(); } } @@ -138,7 +137,7 @@ public void setup() { if (true) { throw org.apache.drill.common.exceptions.UserException.unsupportedError() .message("Only COUNT, MIN and MAX aggregate functions supported for VarChar type") - .build(logger); + .build(); } }