Skip to content

Thread Safety - either fix or document #123

Description

@newcron

Hi Everyone,

I came to notice, that the current Java Client is not thread safe for a couple of reasons:

  • It uses classes that do not support concurrency and yield incorrect results when accessed by multiple threads like HashMap (explanation here)and SimpleDateFormat (explanation here)
  • The results of the last API call are stored in fields inside ApiClient (statusCode and responseHeaders) - which might be overridden by a concurrent request. Accessing that information from the outside may cause incorrect results

I understand that fixing these issues may introduce breaking changes (although using ThreadLocal might be a replacement for statusCode and responseHeader fields) and might not be something to be considered now.

However, I would ask you to at least document the concurrency based limitations of the API client and point out the best way to use the client in a concurrent setup, like a web application.

Thanks a lot

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions