MINOR: WorkerUtils#abort: fix bug in abort logic (#6516)

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 <mumrah@gmail.com>
This commit is contained in:
Colin Patrick McCabe 2019-03-28 14:47:37 -07:00 committed by GitHub
parent d63d702252
commit b25974c387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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);
doneFuture.complete(exception.getMessage());
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);
}