quickstart-java icon indicating copy to clipboard operation
quickstart-java copied to clipboard

Can't shutdown background threads [Firebase Admin SDK 4.1.5]

Open hestad opened this issue 7 years ago • 2 comments

Running this on local machine with Java 8 FirebaseOptions options = new FirebaseOptions.Builder() .setCredential(FirebaseCredentials.applicationDefault()) .setDatabaseUrl("https://" + ServiceOptions.getDefaultProjectId() + ".firebaseio.com/") .build();

firebaseDatabase = FirebaseDatabase.getInstance(FirebaseApp.initializeApp(options)); final DatabaseReference entry = firebaseDatabase.getReference("somereference"); entry.setValue("data",(databaseError, databaseReference) -> System.out.println("ok")); How can i choose to use daemon threads? And if not, why don't you have a shutdown/close option?

I notice that entry.setValue("data") shutdowns threads normally.

hestad avatar Mar 30 '17 16:03 hestad

You can store your listener and ref

private static Map<DatabaseReference, ValueEventListener> valueListenerMap = new ConcurrentHashMap<>(); Then

valueListenerMap.forEach((k, v) -> {
	k.removeEventListener(v);
});

ghost avatar Jan 12 '18 04:01 ghost

@hestad I am not able to use FirebaseOption.setCredentials() method can you help me.

tango4567 avatar Mar 04 '18 14:03 tango4567