Skip to content

Commit 3cf7a96

Browse files
authored
Remove Stream#shouldSupportAdditionalTimeout method (#1227)
Now that Stream is not part of the API, this method can be removed. It only existed due to the possibility that an application creates its own Stream implementation. JAVA-5180
1 parent f4cba1a commit 3cf7a96

11 files changed

+4
-71
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ public ByteBuf read(final int numBytes) throws IOException {
143143
return handler.getRead();
144144
}
145145

146-
@Override
147-
public boolean supportsAdditionalTimeout() {
148-
return true;
149-
}
150-
151146
@Override
152147
public ByteBuf read(final int numBytes, final int additionalTimeout) throws IOException {
153148
FutureAsyncCompletionHandler<ByteBuf> handler = new FutureAsyncCompletionHandler<>();

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
import com.mongodb.event.ConnectionPoolListener;
4444
import com.mongodb.event.ConnectionPoolReadyEvent;
4545
import com.mongodb.event.ConnectionReadyEvent;
46-
import com.mongodb.internal.time.TimePoint;
47-
import com.mongodb.internal.time.Timeout;
4846
import com.mongodb.internal.VisibleForTesting;
4947
import com.mongodb.internal.async.SingleResultCallback;
5048
import com.mongodb.internal.connection.SdamServerDescriptionManager.SdamIssue;
@@ -56,6 +54,8 @@
5654
import com.mongodb.internal.logging.StructuredLogger;
5755
import com.mongodb.internal.session.SessionContext;
5856
import com.mongodb.internal.thread.DaemonThreadFactory;
57+
import com.mongodb.internal.time.TimePoint;
58+
import com.mongodb.internal.time.Timeout;
5959
import com.mongodb.lang.NonNull;
6060
import com.mongodb.lang.Nullable;
6161
import org.bson.ByteBuf;
@@ -777,12 +777,6 @@ public <T> T receive(final Decoder<T> decoder, final SessionContext sessionConte
777777
return wrapped.receive(decoder, sessionContext);
778778
}
779779

780-
@Override
781-
public boolean supportsAdditionalTimeout() {
782-
isTrue("open", !isClosed.get());
783-
return wrapped.supportsAdditionalTimeout();
784-
}
785-
786780
@Override
787781
public <T> T receive(final Decoder<T> decoder, final SessionContext sessionContext, final int additionalTimeout) {
788782
isTrue("open", !isClosed.get());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private ServerDescription lookupServerDescription(final ServerDescription curren
254254
}
255255

256256
private boolean shouldStreamResponses(final ServerDescription currentServerDescription) {
257-
return currentServerDescription.getTopologyVersion() != null && connection.supportsAdditionalTimeout();
257+
return currentServerDescription.getTopologyVersion() != null;
258258
}
259259

260260
private CommandMessage createCommandMessage(final BsonDocument command, final InternalConnection connection,

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ <T> T sendAndReceive(CommandMessage message, Decoder<T> decoder, SessionContext
103103
<T> T receive(Decoder<T> decoder, SessionContext sessionContext);
104104

105105

106-
default boolean supportsAdditionalTimeout() {
107-
return false;
108-
}
109-
110106
default <T> T receive(Decoder<T> decoder, SessionContext sessionContext, int additionalTimeout) {
111107
throw new UnsupportedOperationException();
112108
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,6 @@ public <T> T receive(final Decoder<T> decoder, final SessionContext sessionConte
375375
return receiveCommandMessageResponse(decoder, new NoOpCommandEventSender(), sessionContext, 0);
376376
}
377377

378-
@Override
379-
public boolean supportsAdditionalTimeout() {
380-
return stream.supportsAdditionalTimeout();
381-
}
382-
383378
@Override
384379
public <T> T receive(final Decoder<T> decoder, final SessionContext sessionContext, final int additionalTimeout) {
385380
isTrue("Response is expected", hasMoreToCome);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@ public ByteBuf read(final int numBytes) throws IOException {
186186
}
187187
}
188188

189-
@Override
190-
public boolean supportsAdditionalTimeout() {
191-
return true;
192-
}
193-
194189
@Override
195190
public ByteBuf read(final int numBytes, final int additionalTimeout) throws IOException {
196191
int curTimeout = socket.getSoTimeout();

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

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,16 @@ public interface Stream extends BufferProvider {
6060
*/
6161
ByteBuf read(int numBytes) throws IOException;
6262

63-
/**
64-
* Gets whether this implementation supports specifying an additional timeout for read operations
65-
* <p>
66-
* The default is to not support specifying an additional timeout
67-
* </p>
68-
*
69-
* @return true if this implementation supports specifying an additional timeouts for reads operations
70-
* @see #read(int, int)
71-
*/
72-
default boolean supportsAdditionalTimeout() {
73-
return false;
74-
}
75-
7663
/**
7764
* Read from the stream, blocking until the requested number of bytes have been read. If supported by the implementation,
7865
* adds the given additional timeout to the configured timeout for the stream.
79-
* <p>
80-
* This method should not be called unless {@link #supportsAdditionalTimeout()} returns true.
81-
* </p>
82-
* <p>
83-
* The default behavior is to throw an {@link UnsupportedOperationException}
84-
* </p>
8566
*
8667
* @param numBytes The number of bytes to read into the returned byte buffer
8768
* @param additionalTimeout additional timeout in milliseconds to add to the configured timeout
8869
* @return a byte buffer filled with number of bytes requested
8970
* @throws IOException if there are problems reading from the stream
90-
* @throws UnsupportedOperationException if this implementation does not support additional timeouts
91-
* @see #supportsAdditionalTimeout()
9271
*/
93-
default ByteBuf read(int numBytes, int additionalTimeout) throws IOException {
94-
throw new UnsupportedOperationException();
95-
}
72+
ByteBuf read(int numBytes, int additionalTimeout) throws IOException;
9673

9774
/**
9875
* Write each buffer in the list to the stream in order, asynchronously. This method should return immediately, and invoke the given

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ private static class TlsChannelStream extends AsynchronousChannelStream {
179179
this.selectorMonitor = selectorMonitor;
180180
}
181181

182-
@Override
183-
public boolean supportsAdditionalTimeout() {
184-
return true;
185-
}
186-
187182
@Override
188183
public void openAsync(final AsyncCompletionHandler<Void> handler) {
189184
isTrue("unopened", getChannel() == null);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ public <T> T receive(final Decoder<T> decoder, final SessionContext sessionConte
129129
return result;
130130
}
131131

132-
@Override
133-
public boolean supportsAdditionalTimeout() {
134-
return wrapped.supportsAdditionalTimeout();
135-
}
136-
137132
@Override
138133
public <T> T receive(final Decoder<T> decoder, final SessionContext sessionContext, final int additionalTimeout) {
139134
T result = wrapped.receive(decoder, sessionContext, additionalTimeout);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,6 @@ public ByteBuf read(final int numBytes) throws IOException {
240240
return read(numBytes, 0);
241241
}
242242

243-
@Override
244-
public boolean supportsAdditionalTimeout() {
245-
return true;
246-
}
247-
248243
@Override
249244
public ByteBuf read(final int numBytes, final int additionalTimeoutMillis) throws IOException {
250245
isTrueArgument("additionalTimeoutMillis must not be negative", additionalTimeoutMillis >= 0);

driver-core/src/test/unit/com/mongodb/internal/connection/DefaultServerMonitorSpecification.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ class DefaultServerMonitorSpecification extends Specification {
157157
initialServerDescription
158158
}
159159

160-
supportsAdditionalTimeout() >> true
161-
162160
send(_, _, _) >> { }
163161

164162
receive(_, _) >> {
@@ -238,8 +236,6 @@ class DefaultServerMonitorSpecification extends Specification {
238236
initialServerDescription
239237
}
240238

241-
supportsAdditionalTimeout() >> true
242-
243239
send(_, _, _) >> { }
244240

245241
receive(_, _) >> {

0 commit comments

Comments
 (0)