lhotari commented on pull request #10215:
URL: https://github.com/apache/pulsar/pull/10215#issuecomment-819274254


   > @lhotari please check the answer from @merlimat
   > [#10210 
(comment)](https://github.com/apache/pulsar/issues/10210#issuecomment-819086592)
   
   yes I checked it.
   
   > Probably this is the minimal fix we can do in ClientCtx, that is to 
eagerly initialize all of the fields:
   > 
   > ```
   > @Override
   >     protected void handleGetSchemaResponse(CommandGetSchemaResponse 
commandGetSchemaResponse) {
   >         checkArgument(state == State.Ready);
   > 
   >         long requestId = commandGetSchemaResponse.getRequestId();
   >         commandGetSchemaResponse.getSchema().getSchemaData();
   >         commandGetSchemaResponse.getSchema().getName();
   >         commandGetSchemaResponse.getSchema().getPropertiesList()
   >         commandGetSchemaResponse.getSchema().getType();
   >         CompletableFuture<CommandGetSchemaResponse> future = 
(CompletableFuture<CommandGetSchemaResponse>) pendingRequests
   >                 .remove(requestId);
   >         if (future == null) {
   >             log.warn("{} Received unknown request id from server: {}", 
ctx.channel(), requestId);
   >             return;
   >         }
   >         future.complete(commandGetSchemaResponse);
   >     }
   > ```
   
   This won't work since there is no eager initialization. Please take a look 
at the source code of LightProto generated classes.
   
   A way to do eager initialization would be to move the code for creating 
`SchemaInfo` from `sendGetSchema` method to `handleGetSchemaResponse`. I 
experimented with that here: 
https://github.com/lhotari/pulsar/commit/431b41c5d5ccc5d1a60205c40f3e6cc4721908ce
 .
   It works, but the problem is that Pulsar Proxy depends on the current way 
and that would break. That's the reason why I came back to the solution that I 
have in this PR.


-- 
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