I am using Firebase in a Spring MVC app in tomcat. It seems firebase creates a non-daemon thread that prevents tomcat from shutting down.
How do I terminate/shutdown Firebase in my Spring app?
This is how I am using Firebase:
private static Firebase getUserRef(String username)
{
Firebase ref = new Firebase("https://<firebaseurl>");
return ref.child(username);
}
private static void createUserName(final String name)
{
final Firebase userref = getUserRef(name);
userref.addListenerForSingleValueEvent(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshot)
{
Object value = dataSnapshot.getValue();
// logic
}
@Override
public void onCancelled(FirebaseError firebaseError)
{
}
});
}
The createUserName()
method is called inside a controller method.
Should I be using beans?
This issue has been fixed as of v1.0.15 of the Firebase Java Client. You can download the latest version here: https://www.firebase.com/docs/java-quickstart.html
Firebase now creates only daemon threads, so your process will exit cleanly as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With