Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,13 @@ protected static boolean isRedirectException(Throwable ex) {
== Status.TEMPORARY_REDIRECT.getStatusCode();
}

protected static boolean isNotFoundException(Throwable ex) {
Throwable realCause = FutureUtil.unwrapCompletionException(ex);
return realCause instanceof WebApplicationException
&& ((WebApplicationException) realCause).getResponse().getStatus()
== Status.NOT_FOUND.getStatusCode();
}

protected static String getTopicNotFoundErrorMessage(String topic) {
return String.format("Topic %s not found", topic);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,10 @@ private CompletableFuture<Void> validateOwnershipAndOperationAsync(boolean autho
.thenCompose(__ -> validateTopicOperationAsync(topicName, operation));
}


protected boolean shouldPrintErrorLog(Throwable ex) {
return !isRedirectException(ex) && !isNotFoundException(ex);
}

private static final Logger log = LoggerFactory.getLogger(SchemasResourceBase.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public void getSchema(
) {
validateTopicName(tenant, cluster, namespace, topic);
getSchemaAsync(authoritative)
.thenApply(schemaAndMetadata -> convertToSchemaResponse(schemaAndMetadata))
.thenApply(this::convertToSchemaResponse)
.thenApply(response::resume)
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get schema for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -124,10 +124,10 @@ public void getSchema(
) {
validateTopicName(tenant, cluster, namespace, topic);
getSchemaAsync(authoritative, version)
.thenApply(schemaAndMetadata -> convertToSchemaResponse(schemaAndMetadata))
.thenApply(this::convertToSchemaResponse)
.thenAccept(response::resume)
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get schema for topic {} with version {}",
clientAppId(), topicName, version, ex);
}
Expand Down Expand Up @@ -159,10 +159,10 @@ public void getAllSchemas(
) {
validateTopicName(tenant, cluster, namespace, topic);
getAllSchemasAsync(authoritative)
.thenApply(schemaAndMetadata -> convertToAllVersionsSchemaResponse(schemaAndMetadata))
.thenApply(this::convertToAllVersionsSchemaResponse)
.thenAccept(response::resume)
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get all schemas for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -197,7 +197,7 @@ public void deleteSchema(
response.resume(DeleteSchemaResponse.builder().version(getLongSchemaVersion(version)).build());
})
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to delete schemas for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -252,7 +252,7 @@ public void postSchema(
response.resume(Response.status(422, /* Unprocessable Entity */
root.getMessage()).build());
} else {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to post schemas for topic {}", clientAppId(), topicName, root);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -301,7 +301,7 @@ public void testCompatibility(
.schemaCompatibilityStrategy(pair.getRight().name()).build())
.build()))
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to test compatibility for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -347,7 +347,7 @@ public void getVersionBySchema(
getVersionBySchemaAsync(payload, authoritative)
.thenAccept(version -> response.resume(LongSchemaVersionResponse.builder().version(version).build()))
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get version by schema for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public void getSchema(
@Suspended final AsyncResponse response) {
validateTopicName(tenant, namespace, topic);
getSchemaAsync(authoritative)
.thenApply(schemaAndMetadata -> convertToSchemaResponse(schemaAndMetadata))
.thenApply(this::convertToSchemaResponse)
.thenApply(response::resume)
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get schema for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -122,10 +122,10 @@ public void getSchema(
@Suspended final AsyncResponse response) {
validateTopicName(tenant, namespace, topic);
getSchemaAsync(authoritative, version)
.thenApply(schemaAndMetadata -> convertToSchemaResponse(schemaAndMetadata))
.thenApply(this::convertToSchemaResponse)
.thenAccept(response::resume)
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get schema for topic {} with version {}",
clientAppId(), topicName, version, ex);
}
Expand Down Expand Up @@ -155,10 +155,10 @@ public void getAllSchemas(
@Suspended final AsyncResponse response) {
validateTopicName(tenant, namespace, topic);
getAllSchemasAsync(authoritative)
.thenApply(schemaAndMetadata -> convertToAllVersionsSchemaResponse(schemaAndMetadata))
.thenApply(this::convertToAllVersionsSchemaResponse)
.thenAccept(response::resume)
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get all schemas for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -191,7 +191,7 @@ public void deleteSchema(
response.resume(DeleteSchemaResponse.builder().version(getLongSchemaVersion(version)).build());
})
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to delete schemas for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -238,7 +238,7 @@ public void postSchema(
response.resume(Response.status(422, /* Unprocessable Entity */
root.getMessage()).build());
} else {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to post schemas for topic {}", clientAppId(), topicName, root);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -278,7 +278,7 @@ public void testCompatibility(
.schemaCompatibilityStrategy(pair.getRight().name()).build())
.build()))
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to test compatibility for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down Expand Up @@ -315,7 +315,7 @@ public void getVersionBySchema(
getVersionBySchemaAsync(payload, authoritative)
.thenAccept(version -> response.resume(LongSchemaVersionResponse.builder().version(version).build()))
.exceptionally(ex -> {
if (!isRedirectException(ex)) {
if (shouldPrintErrorLog(ex)) {
log.error("[{}] Failed to get version by schema for topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(response, ex);
Expand Down