freeznet commented on a change in pull request #10513:
URL: https://github.com/apache/pulsar/pull/10513#discussion_r629870150



##########
File path: 
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java
##########
@@ -1397,9 +1399,14 @@ public OffloadProcessStatus offloadStatus(String topic)
         WebTarget path = topicPath(tn, "offload");
         final CompletableFuture<OffloadProcessStatus> future = new 
CompletableFuture<>();
         asyncGetRequest(path,
-                new InvocationCallback<OffloadProcessStatus>() {
+                new InvocationCallback<String>() {
                     @Override
-                    public void completed(OffloadProcessStatus 
offloadProcessStatus) {
+                    public void completed(String jsonString) {
+                        Gson gson = new 
GsonBuilder().registerTypeAdapter(MessageId.class,

Review comment:
       The reason why I use `Gson` here is that I noticed `TopicsImpl.java` is 
using `Gson` to de REST response to `JsonObject` already, like 
`getInternalInfoAsync`, so I havent try `Jackson` here to avoid additional 
imports. 
   
   And in this case, we want de `MessageId.class` to `MessageIdImpl.class`, 
`Gson` have a simpler way to map interface (`MessageId.class`) with 
implementation class (`MessageIdImpl.class`), for `Jackson` we cannot use 
`@JsonDeserialize` annotation because we dont want to have `Jackson` dependency 
in `pulsar-client-admin-api`, but I have googled with a solution with 
`SimpleAbstractTypeResolver`, like
   
   ```
   ObjectMapper mapper = ObjectMapperFactory.create();
   SimpleModule module = new SimpleModule("OffloadProcessStatusConvertModule",
           Version.unknownVersion());
   
   SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
   resolver.addMapping(MessageId.class, MessageIdImpl.class);
   
   module.setAbstractTypes(resolver);
   mapper.registerModule(module);
   ```
   
   So if we want to use Jackson here, we may try this way.
   
   Also I do confuse with `Gson` and `Jackson` here in Pulsar, do we want to 
replace `Gson` with `Jackson`, or we will keep the mixed usage but prefer 
`Jackson` by default? And what are the concerns? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to