Skip to content

Commit

Permalink
[fix][ml] Fix potential NPE cause future never complete. (#19415)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattisonchao authored Feb 3, 2023
1 parent f0d66d4 commit 11073fd
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,11 @@ private CompletableFuture<List<SchemaAndMetadata>> trimDeletedSchemaAndGetList(S
schemaFutureList.thenCompose(FutureUtils::collect).handle((schemaList, ex) -> {
List<SchemaAndMetadata> list = ex != null ? new ArrayList<>() : schemaList;
if (ex != null) {
boolean recoverable = ex.getCause() != null && (ex.getCause() instanceof SchemaException)
? ((SchemaException) ex.getCause()).isRecoverable()
: true;
final Throwable rc = FutureUtil.unwrapCompletionException(ex);
boolean recoverable = !(rc instanceof SchemaException) || ((SchemaException) rc).isRecoverable();
// if error is recoverable then fail the request.
if (recoverable) {
schemaResult.completeExceptionally(ex.getCause());
schemaResult.completeExceptionally(rc);
return null;
}
// clean the schema list for recoverable and delete the schema from zk
Expand All @@ -570,7 +569,7 @@ private CompletableFuture<List<SchemaAndMetadata>> trimDeletedSchemaAndGetList(S
trimDeletedSchemaAndGetList(list);
// clean up the broken schema from zk
deleteSchemaStorage(schemaId, true).handle((sv, th) -> {
log.info("Clean up non-recoverable schema {}. Deletion of schema {} {}", ex.getCause().getMessage(),
log.info("Clean up non-recoverable schema {}. Deletion of schema {} {}", rc.getMessage(),
schemaId, (th == null ? "successful" : "failed, " + th.getCause().getMessage()));
schemaResult.complete(list);
return null;
Expand Down

0 comments on commit 11073fd

Please sign in to comment.