From c67deb1359432f46861e28d603023adc0611a202 Mon Sep 17 00:00:00 2001 From: fengyubiao Date: Wed, 20 Mar 2024 02:45:48 +0800 Subject: [PATCH 1/2] - --- .../admin/impl/SchemasResourceBase.java | 4 +- .../org/apache/pulsar/schema/SchemaTest.java | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) 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..eef81a98c5ba0 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 @@ -258,7 +258,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 +275,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; From d951fb17f9f36cf833694d5400af873989e2bb80 Mon Sep 17 00:00:00 2001 From: fengyubiao Date: Wed, 20 Mar 2024 11:02:34 +0800 Subject: [PATCH 2/2] check style --- .../org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java | 1 - 1 file changed, 1 deletion(-) 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 eef81a98c5ba0..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;