I want to use the Firebase Admin SDK to validate JWT tokens. I am using undertow.io as my HTTP library. Undertow creates multiple thread to handle connections.
Do I need to make the FirebaseApp
or FirebaseAuth
object thread locale, or can I just execute the method getInstance
and let the SDK take care of it?
It is thread-safe in java. Anything that doesn't require a listener will be a synchronous thread-safe operation for the firebase admin java sdk.
With the listeners such as 'OnValueChanged', you will find that your code won't compile if you try to access variables from within or pass values from outside. In those cases you have to use 'Atomic' versions of each variable such as AtomicInteger which will automatically block and ensure thread safety if multiple threads try to access that variable.