swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[java] Retrofit simplexml converter and retrofit client object thread safety

Open sbelan opened this issue 10 years ago • 8 comments

@wing328

  1. We are using retrofit-simplexml combination to send and receive xml payload using 2.1.5. Simplexml expects annotations based on element type. For e.g. primitive types should have @Element annotation, while list should have @ElementList, and arrays as @ElementArray. Mustache being logic-less, I can not add string comparison, but can surely check for Boolean. But, model json does not contain any Boolean like isArray, isList etc. In 2.1.5, I am trying to use isContainer, but that is common for both array/list/map. Other option is to use VendorExtension to identify type.

But, would like to know from you,

  1. if there is any better way that I missed?
  2. Is there any plan to add some Booleans like mentioned above in 2.1.6 .. given the nature of mustache language?
  3. Can retrofit client object be shared across multiple concurrent requests? Is retrofit client object re-entrant?

sbelan avatar Feb 04 '16 12:02 sbelan

For your questions related to Retrofit clients, let me cc @cbornet who's the expert in the Retrofit API client.

For your questions related to model json, I need to check. How urgent do you need the "feature" (if it's not yet implemented)?

wing328 avatar Feb 04 '16 16:02 wing328

The retrofit adapter and services are thread-safe and the ApiClient is just a wrapper to configure them. So everything should be fine once the ApiClient is created and configured. Depending on your implementation, you should probably wrap the ApiClient into a singleton. Note : If you use OAuth2, there is a little bit more custom code to handle the access_token (which is shared between threads). This code should also be thread-safe. Please report if you find an issue there.

cbornet avatar Feb 04 '16 18:02 cbornet

@cbornet .. that's great :+1: ...thanks for your reply. @wing328 Right now we are achieving above using vendor extension. But it would be great if you add few more Boolean for models as mustache is logic less. It will be get if we get this in coming 2.1.6 release.

sbelan avatar Feb 05 '16 09:02 sbelan

@sbelan your request is definitely reasonable. Can you list out all the boolean you want us to add to meet your requirement?

wing328 avatar Feb 05 '16 09:02 wing328

@wing328 thanks for quick assist :+1: We are expecting all collection datatypes like map, list etc and primitives. We came across to this issue for to use list and map.

sbelan avatar Feb 05 '16 10:02 sbelan

To manage your expectation, I think it's reasonable to expect these additional features will be available in 2.1.6 stable release based on my estimation.

wing328 avatar Feb 05 '16 14:02 wing328

@wing328 ... that's great :+1:

sbelan avatar Feb 08 '16 06:02 sbelan

@sbelan PR merged. Please pull the latest master and help run some tests to see if those additional boolean flags meet your needs.

wing328 avatar Feb 24 '16 14:02 wing328