Skip to content

Commit 047362b

Browse files
committed
Remove deprecated connection pool-event related classes/methods
* ConnectionPoolOpenedEvent * ConnectionAddedEvent * ConnectionRemovedEvent * ConnectionPoolListener#connectionPoolOpened * ConnectionPoolListener#connectionAdded * ConnectionPoolListener#connectionRemoved JAVA-5151
1 parent 59f8e65 commit 047362b

File tree

11 files changed

+24
-392
lines changed

11 files changed

+24
-392
lines changed

driver-core/src/main/com/mongodb/event/ConnectionAddedEvent.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

driver-core/src/main/com/mongodb/event/ConnectionPoolListener.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@
2424
* @since 3.5
2525
*/
2626
public interface ConnectionPoolListener extends EventListener {
27-
/**
28-
* Invoked when a connection pool is opened. The default implementation does nothing.
29-
*
30-
* @param event the event
31-
* @deprecated Prefer {@link #connectionPoolCreated} Implementations should NOT implement this method at all, instead relying on
32-
* the default no-op implementation. If an application implements both this method and connectionPoolCreated, the application risks
33-
* double-counting events.
34-
*/
35-
@Deprecated
36-
default void connectionPoolOpened(ConnectionPoolOpenedEvent event) {
37-
}
38-
3927
/**
4028
* Invoked when a connection pool is created. The default implementation does nothing.
4129
*
@@ -105,18 +93,6 @@ default void connectionCheckOutFailed(ConnectionCheckOutFailedEvent event) {
10593
default void connectionCheckedIn(ConnectionCheckedInEvent event) {
10694
}
10795

108-
/**
109-
* Invoked when a connection is added to a pool. The default implementation does nothing.
110-
*
111-
* @param event the event
112-
* @deprecated Prefer {@link #connectionCreated} Implementations should NOT implement this method at all, instead relying on
113-
* the default no-op implementation. If an application implements both this method and connectionCreated, the application risks
114-
* double-counting events.
115-
*/
116-
@Deprecated
117-
default void connectionAdded(ConnectionAddedEvent event) {
118-
}
119-
12096
/**
12197
* Invoked when a connection is created. The default implementation does nothing.
12298
*
@@ -135,18 +111,6 @@ default void connectionCreated(ConnectionCreatedEvent event) {
135111
default void connectionReady(ConnectionReadyEvent event) {
136112
}
137113

138-
/**
139-
* Invoked when a connection is removed from a pool. The default implementation does nothing.
140-
*
141-
* @param event the event
142-
* @deprecated Prefer {@link #connectionClosed} Implementations should NOT implement this method at all, instead relying on
143-
* the default no-op implementation. If an application implements both this method and connectionClosed, the application risks
144-
* double-counting events.
145-
*/
146-
@Deprecated
147-
default void connectionRemoved(ConnectionRemovedEvent event) {
148-
}
149-
150114
/**
151115
* Invoked when a connection is removed from a pool. The default implementation does nothing.
152116
*

driver-core/src/main/com/mongodb/event/ConnectionPoolOpenedEvent.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

driver-core/src/main/com/mongodb/event/ConnectionRemovedEvent.java

Lines changed: 0 additions & 111 deletions
This file was deleted.

driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,13 @@ private void connectionPoolCreated(final ConnectionPoolListener connectionPoolLi
498498
logMessage("Connection pool created", clusterId, message, entries);
499499
}
500500
connectionPoolListener.connectionPoolCreated(new ConnectionPoolCreatedEvent(serverId, settings));
501-
connectionPoolListener.connectionPoolOpened(new com.mongodb.event.ConnectionPoolOpenedEvent(serverId, settings));
502501
}
503502

504503
/**
505504
* Send both current and deprecated events in order to preserve backwards compatibility.
506505
* Must not throw {@link Exception}s.
507506
*
508-
* @return A {@link TimePoint} after executing {@link ConnectionPoolListener#connectionAdded(com.mongodb.event.ConnectionAddedEvent)},
507+
* @return A {@link TimePoint} after executing {@link ConnectionPoolListener#connectionCreated(ConnectionCreatedEvent)},
509508
* {@link ConnectionPoolListener#connectionCreated(ConnectionCreatedEvent)}.
510509
* This order is required by
511510
* <a href="https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#events">CMAP</a>
@@ -516,7 +515,6 @@ private TimePoint connectionCreated(final ConnectionPoolListener connectionPoolL
516515
"Connection created: address={}:{}, driver-generated ID={}",
517516
connectionId.getLocalValue());
518517

519-
connectionPoolListener.connectionAdded(new com.mongodb.event.ConnectionAddedEvent(connectionId));
520518
connectionPoolListener.connectionCreated(new ConnectionCreatedEvent(connectionId));
521519
return TimePoint.now();
522520
}
@@ -541,7 +539,6 @@ private void connectionClosed(final ConnectionPoolListener connectionPoolListene
541539
"Connection closed: address={}:{}, driver-generated ID={}. Reason: {}.[ Error: {}]",
542540
entries);
543541
}
544-
connectionPoolListener.connectionRemoved(new com.mongodb.event.ConnectionRemovedEvent(connectionId, getReasonForRemoved(reason)));
545542
connectionPoolListener.connectionClosed(new ConnectionClosedEvent(connectionId, reason));
546543
}
547544

@@ -577,27 +574,6 @@ private TimePoint connectionCheckoutStarted(final OperationContext operationCont
577574
return TimePoint.now();
578575
}
579576

580-
private com.mongodb.event.ConnectionRemovedEvent.Reason getReasonForRemoved(final ConnectionClosedEvent.Reason reason) {
581-
com.mongodb.event.ConnectionRemovedEvent.Reason removedReason = com.mongodb.event.ConnectionRemovedEvent.Reason.UNKNOWN;
582-
switch (reason) {
583-
case STALE:
584-
removedReason = com.mongodb.event.ConnectionRemovedEvent.Reason.STALE;
585-
break;
586-
case IDLE:
587-
removedReason = com.mongodb.event.ConnectionRemovedEvent.Reason.MAX_IDLE_TIME_EXCEEDED;
588-
break;
589-
case ERROR:
590-
removedReason = com.mongodb.event.ConnectionRemovedEvent.Reason.ERROR;
591-
break;
592-
case POOL_CLOSED:
593-
removedReason = com.mongodb.event.ConnectionRemovedEvent.Reason.POOL_CLOSED;
594-
break;
595-
default:
596-
break;
597-
}
598-
return removedReason;
599-
}
600-
601577
/**
602578
* Must not throw {@link Exception}s.
603579
*/

0 commit comments

Comments
 (0)