Skip to content

Commit 4d29623

Browse files
committed
Protect against misbehaving listeners during session init
1 parent 990c7c6 commit 4d29623

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/session/DefaultSession.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,36 @@ private void notifyListeners() {
484484
t);
485485
}
486486
}
487-
context.getNodeStateListener().onSessionReady(DefaultSession.this);
488-
schemaListenerNotifier.onSessionReady(DefaultSession.this);
489-
context.getRequestTracker().onSessionReady(DefaultSession.this);
487+
try {
488+
context.getNodeStateListener().onSessionReady(DefaultSession.this);
489+
} catch (Throwable t) {
490+
Loggers.warnWithException(
491+
LOG,
492+
"[{}] Error while notifying {} of session ready",
493+
logPrefix,
494+
context.getNodeStateListener(),
495+
t);
496+
}
497+
try {
498+
schemaListenerNotifier.onSessionReady(DefaultSession.this);
499+
} catch (Throwable t) {
500+
Loggers.warnWithException(
501+
LOG,
502+
"[{}] Error while notifying {} of session ready",
503+
logPrefix,
504+
schemaListenerNotifier,
505+
t);
506+
}
507+
try {
508+
context.getRequestTracker().onSessionReady(DefaultSession.this);
509+
} catch (Throwable t) {
510+
Loggers.warnWithException(
511+
LOG,
512+
"[{}] Error while notifying {} of session ready",
513+
logPrefix,
514+
context.getRequestTracker(),
515+
t);
516+
}
490517
}
491518

492519
private void onNodeStateChanged(NodeStateEvent event) {

0 commit comments

Comments
 (0)