3

I have an (external) factory class which lazy-initializes a CXF client in a non thread-safe way.
(It is possible that it instantiates the client two or more times if called too quickly.)

The class has a protected method which does the initialization. It calls the method on the first request.

Should I create my own client bypassing the factory?
Somehow make the class initialize the client by sending one request on a single thread / call the protected method?

Or is it safe to ignore this as it happens on the first few requests?

1 Answers1

5

If you want to be sure that the initialization happens in a safe way you can call the setup method from your own code using reflective access to the protected method.

I would talk to the provider of the library to document the proper and save way for initialization. The behavior you describe looks like a bug of the factory / library to me.

Thomas
  • 11,272
  • 2
  • 24
  • 40