diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java index b9533c6f29192..5bef4ccd0aa61 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.stream.Collectors; import javax.ws.rs.container.AsyncResponse; -import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.pulsar.broker.admin.AdminResource; import org.apache.pulsar.broker.service.schema.SchemaRegistry.SchemaAndMetadata; @@ -258,7 +257,7 @@ private static void handleGetSchemaResponse(AsyncResponse response, SchemaAndMet response.resume(Response.status( Response.Status.NOT_FOUND.getStatusCode(), "Schema is deleted").build()); } else { - response.resume(Response.ok().encoding(MediaType.APPLICATION_JSON) + response.resume(Response.ok() .entity(convertSchemaAndMetadataToGetSchemaResponse(schema)).build()); } } else { @@ -275,7 +274,7 @@ private static void handleGetAllSchemasResponse(AsyncResponse response, List response = new CompletableFuture(); + schemas.asyncGetRequest(path, new InvocationCallback() { + + @Override + public void completed(javax.ws.rs.core.Response getSchemaResponse) { + response.complete(getSchemaResponse); + } + + @Override + public void failed(Throwable throwable) { + response.completeExceptionally(throwable); + } + }); + MultivaluedMap responseHeaders = response.join().getHeaders(); + assertTrue(!responseHeaders.containsKey(HttpHeaders.CONTENT_ENCODING) + || !responseHeaders.get(HttpHeaders.CONTENT_ENCODING).toString().contains("application/json")); + assertTrue(responseHeaders.containsKey(HttpHeaders.CONTENT_TYPE) + && responseHeaders.get(HttpHeaders.CONTENT_TYPE).toString().contains("application/json")); + } + @EqualsAndHashCode static class User implements Serializable { private String name;