MINOR: WorkerUtils#abort: fix bug in abort logic
doneFuture is supposed to be completed with an empty string (meaning success) or a non-empty string which is the error message.  Currently, due to exception.getMessage sometimes returning null or an empty string, this is not working correctly.  This patch fixes that.
Reviewers: David Arthur
@@ -62,8 +62,12 @@ public final class WorkerUtils {
*/
public static void abort(Logger log, String what, Throwable exception,
KafkaFutureImpl<String> doneFuture) throws KafkaException {
- log.warn("{} caught an exception: ", what, exception);
+ log.warn("{} caught an exception", what, exception);
+ if (exception.getMessage() == null || exception.getMessage().isEmpty()) {
+ doneFuture.complete(exception.getClass().getCanonicalName());
+ } else {
doneFuture.complete(exception.getMessage());
+ }
throw new KafkaException(exception);
}
