Skip to content

Commit f4a2990

Browse files
committed
Remove Stream-related types from API
MongoClientSettings#getStreamFactoryFactory() MongoClientSettings.Builder#streamFactoryFactory(StreamFactoryFactory) AsynchronousSocketChannelStreamFactory AsynchronousSocketChannelStreamFactoryFactory BufferProvider SocketStreamFactory Stream StreamFactory StreamFactoryFactory TlsChannelStreamFactoryFactory NettyStreamFactory NettyStreamFactoryFactory JAVA-5161
1 parent 3f99fe3 commit f4a2990

File tree

67 files changed

+115
-527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+115
-527
lines changed

driver-core/src/main/com/mongodb/MongoClientSettings.java

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.mongodb.connection.ServerSettings;
2727
import com.mongodb.connection.SocketSettings;
2828
import com.mongodb.connection.SslSettings;
29-
import com.mongodb.connection.StreamFactoryFactory;
3029
import com.mongodb.connection.TransportSettings;
3130
import com.mongodb.event.CommandListener;
3231
import com.mongodb.lang.Nullable;
@@ -63,7 +62,6 @@
6362
*
6463
* @since 3.7
6564
*/
66-
@SuppressWarnings("deprecation")
6765
@Immutable
6866
public final class MongoClientSettings {
6967
private static final CodecRegistry DEFAULT_CODEC_REGISTRY =
@@ -92,7 +90,6 @@ public final class MongoClientSettings {
9290
private final ReadConcern readConcern;
9391
private final MongoCredential credential;
9492
private final TransportSettings transportSettings;
95-
private final StreamFactoryFactory streamFactoryFactory;
9693
private final List<CommandListener> commandListeners;
9794
private final CodecRegistry codecRegistry;
9895
private final LoggerSettings loggerSettings;
@@ -213,7 +210,6 @@ public static final class Builder {
213210
private ReadConcern readConcern = ReadConcern.DEFAULT;
214211
private CodecRegistry codecRegistry = MongoClientSettings.getDefaultCodecRegistry();
215212
private TransportSettings transportSettings;
216-
private StreamFactoryFactory streamFactoryFactory;
217213
private List<CommandListener> commandListeners = new ArrayList<>();
218214

219215
private final LoggerSettings.Builder loggerSettingsBuilder = LoggerSettings.builder();
@@ -257,7 +253,6 @@ private Builder(final MongoClientSettings settings) {
257253
dnsClient = settings.getDnsClient();
258254
inetAddressResolver = settings.getInetAddressResolver();
259255
transportSettings = settings.getTransportSettings();
260-
streamFactoryFactory = settings.getStreamFactoryFactory();
261256
autoEncryptionSettings = settings.getAutoEncryptionSettings();
262257
contextProvider = settings.getContextProvider();
263258
loggerSettingsBuilder.applySettings(settings.getLoggerSettings());
@@ -489,27 +484,9 @@ public Builder codecRegistry(final CodecRegistry codecRegistry) {
489484
return this;
490485
}
491486

492-
/**
493-
* Sets the factory to use to create a {@code StreamFactory}.
494-
*
495-
* @param streamFactoryFactory the stream factory factory
496-
* @return this
497-
* @see #getStreamFactoryFactory()
498-
* @deprecated Prefer {@link #transportSettings(TransportSettings)}
499-
*/
500-
@Deprecated
501-
public Builder streamFactoryFactory(final StreamFactoryFactory streamFactoryFactory) {
502-
this.streamFactoryFactory = notNull("streamFactoryFactory", streamFactoryFactory);
503-
return this;
504-
}
505-
506487
/**
507488
* Sets the {@link TransportSettings} to apply.
508489
*
509-
* <p>
510-
* If transport settings are applied, application of {@link #streamFactoryFactory} is ignored.
511-
* </p>
512-
*
513490
* @param transportSettings the transport settings
514491
* @return this
515492
* @see #getTransportSettings()
@@ -789,19 +766,6 @@ public CodecRegistry getCodecRegistry() {
789766
return codecRegistry;
790767
}
791768

792-
/**
793-
* Gets the factory to use to create a {@code StreamFactory}.
794-
*
795-
* @return the stream factory factory
796-
* @see Builder#streamFactoryFactory(StreamFactoryFactory)
797-
* @deprecated Prefer {@link #getTransportSettings()}
798-
*/
799-
@Deprecated
800-
@Nullable
801-
public StreamFactoryFactory getStreamFactoryFactory() {
802-
return streamFactoryFactory;
803-
}
804-
805769
/**
806770
* Gets the settings for the underlying transport implementation
807771
*
@@ -1017,7 +981,6 @@ public boolean equals(final Object o) {
1017981
&& Objects.equals(readConcern, that.readConcern)
1018982
&& Objects.equals(credential, that.credential)
1019983
&& Objects.equals(transportSettings, that.transportSettings)
1020-
&& Objects.equals(streamFactoryFactory, that.streamFactoryFactory)
1021984
&& Objects.equals(commandListeners, that.commandListeners)
1022985
&& Objects.equals(codecRegistry, that.codecRegistry)
1023986
&& Objects.equals(loggerSettings, that.loggerSettings)
@@ -1040,7 +1003,7 @@ public boolean equals(final Object o) {
10401003
@Override
10411004
public int hashCode() {
10421005
return Objects.hash(readPreference, writeConcern, retryWrites, retryReads, readConcern, credential, transportSettings,
1043-
streamFactoryFactory, commandListeners, codecRegistry, loggerSettings, clusterSettings, socketSettings,
1006+
commandListeners, codecRegistry, loggerSettings, clusterSettings, socketSettings,
10441007
heartbeatSocketSettings, connectionPoolSettings, serverSettings, sslSettings, applicationName, compressorList,
10451008
uuidRepresentation, serverApi, autoEncryptionSettings, heartbeatSocketTimeoutSetExplicitly,
10461009
heartbeatConnectTimeoutSetExplicitly, dnsClient, inetAddressResolver, contextProvider);
@@ -1056,7 +1019,6 @@ public String toString() {
10561019
+ ", readConcern=" + readConcern
10571020
+ ", credential=" + credential
10581021
+ ", transportSettings=" + transportSettings
1059-
+ ", streamFactoryFactory=" + streamFactoryFactory
10601022
+ ", commandListeners=" + commandListeners
10611023
+ ", codecRegistry=" + codecRegistry
10621024
+ ", loggerSettings=" + loggerSettings
@@ -1085,7 +1047,6 @@ private MongoClientSettings(final Builder builder) {
10851047
readConcern = builder.readConcern;
10861048
credential = builder.credential;
10871049
transportSettings = builder.transportSettings;
1088-
streamFactoryFactory = builder.streamFactoryFactory;
10891050
codecRegistry = builder.codecRegistry;
10901051
commandListeners = builder.commandListeners;
10911052
applicationName = builder.applicationName;

driver-core/src/main/com/mongodb/connection/ProxySettings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.mongodb.AutoEncryptionSettings;
2020
import com.mongodb.ClientEncryptionSettings;
2121
import com.mongodb.ConnectionString;
22+
import com.mongodb.MongoClientSettings;
2223
import com.mongodb.annotations.Immutable;
2324
import com.mongodb.lang.Nullable;
2425

@@ -35,7 +36,7 @@
3536
* This setting is furthermore ignored if:
3637
* <ul>
3738
* <li>the communication is via {@linkplain com.mongodb.UnixServerAddress Unix domain socket}.</li>
38-
* <li>a {@link StreamFactoryFactory} is {@linkplain com.mongodb.MongoClientSettings.Builder#streamFactoryFactory(StreamFactoryFactory)
39+
* <li>a {@link TransportSettings} is {@linkplain MongoClientSettings.Builder#transportSettings(TransportSettings)}
3940
* configured}.</li>
4041
* </ul>
4142
*

driver-core/src/main/com/mongodb/connection/SslSettings.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ public Builder invalidHostNameAllowed(final boolean invalidHostNameAllowed) {
112112
/**
113113
* Sets the SSLContext for use when SSL is enabled.
114114
*
115-
* @param context the SSLContext to use for connections. Ignored if TLS/SSL is not {@linkplain #enabled(boolean) enabled},
116-
* or if a {@link StreamFactory} {@linkplain StreamFactoryFactory#create(SocketSettings, SslSettings) created}
117-
* by the {@linkplain com.mongodb.MongoClientSettings.Builder#streamFactoryFactory(StreamFactoryFactory) specified}
118-
* {@link StreamFactoryFactory} does not use {@link SSLContext}.
115+
* @param context the SSLContext to use for connections. Ignored if TLS/SSL is not {@linkplain #enabled(boolean) enabled}, or if
116+
* overridden by {@link NettyTransportSettings#getSslContext()}.
119117
* @return this
120118
* @since 3.5
121119
*/

driver-core/src/main/com/mongodb/connection/netty/package-info.java

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

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.mongodb.ServerAddress;
2424
import com.mongodb.connection.AsyncCompletionHandler;
2525
import com.mongodb.connection.SocketSettings;
26-
import com.mongodb.connection.Stream;
2726
import com.mongodb.lang.Nullable;
2827
import org.bson.ByteBuf;
2928

@@ -43,7 +42,6 @@
4342
/**
4443
* <p>This class is not part of the public API and may be removed or changed at any time</p>
4544
*/
46-
@SuppressWarnings("deprecation")
4745
public abstract class AsynchronousChannelStream implements Stream {
4846
private final ServerAddress serverAddress;
4947
private final SocketSettings settings;

driver-core/src/main/com/mongodb/connection/AsynchronousSocketChannelStreamFactory.java renamed to driver-core/src/main/com/mongodb/internal/connection/AsynchronousSocketChannelStreamFactory.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,21 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.mongodb.connection;
17+
package com.mongodb.internal.connection;
1818

1919
import com.mongodb.ServerAddress;
20-
import com.mongodb.internal.connection.AsynchronousSocketChannelStream;
21-
import com.mongodb.internal.connection.PowerOfTwoBufferPool;
20+
import com.mongodb.connection.SocketSettings;
21+
import com.mongodb.connection.SslSettings;
2222
import com.mongodb.lang.Nullable;
2323

2424
import java.nio.channels.AsynchronousChannelGroup;
2525

26+
import static com.mongodb.assertions.Assertions.assertFalse;
2627
import static com.mongodb.assertions.Assertions.notNull;
2728

2829
/**
2930
* Factory to create a Stream that's an AsynchronousSocketChannelStream. Throws an exception if SSL is enabled.
30-
*
31-
* @since 3.0
32-
* @deprecated There is no replacement for this class.
3331
*/
34-
@Deprecated
3532
public class AsynchronousSocketChannelStreamFactory implements StreamFactory {
3633
private final PowerOfTwoBufferPool bufferProvider = PowerOfTwoBufferPool.DEFAULT;
3734
private final SocketSettings settings;
@@ -58,10 +55,7 @@ public AsynchronousSocketChannelStreamFactory(final SocketSettings settings, fin
5855
*/
5956
public AsynchronousSocketChannelStreamFactory(final SocketSettings settings, final SslSettings sslSettings,
6057
@Nullable final AsynchronousChannelGroup group) {
61-
if (sslSettings.isEnabled()) {
62-
throw new UnsupportedOperationException("No SSL support in java.nio.channels.AsynchronousSocketChannel. For SSL support use "
63-
+ "com.mongodb.connection.TlsChannelStreamFactoryFactory");
64-
}
58+
assertFalse(sslSettings.isEnabled());
6559

6660
this.settings = notNull("settings", settings);
6761
this.group = group;

driver-core/src/main/com/mongodb/connection/AsynchronousSocketChannelStreamFactoryFactory.java renamed to driver-core/src/main/com/mongodb/internal/connection/AsynchronousSocketChannelStreamFactoryFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.mongodb.connection;
17+
package com.mongodb.internal.connection;
18+
19+
import com.mongodb.connection.SocketSettings;
20+
import com.mongodb.connection.SslSettings;
1821

1922
import java.nio.channels.AsynchronousChannelGroup;
2023

2124
/**
2225
* A {@code StreamFactoryFactory} implementation for AsynchronousSocketChannel-based streams.
2326
*
2427
* @see java.nio.channels.AsynchronousSocketChannel
25-
* @since 3.1
26-
* @deprecated There is no replacement for this class.
2728
*/
28-
@Deprecated
2929
public final class AsynchronousSocketChannelStreamFactoryFactory implements StreamFactoryFactory {
3030
private final AsynchronousChannelGroup group;
3131

driver-core/src/main/com/mongodb/connection/BufferProvider.java renamed to driver-core/src/main/com/mongodb/internal/connection/BufferProvider.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.mongodb.connection;
17+
package com.mongodb.internal.connection;
1818

1919
import com.mongodb.annotations.ThreadSafe;
2020
import org.bson.ByteBuf;
2121

2222
/**
2323
* A provider of instances of ByteBuf.
24-
*
25-
* @since 3.0
26-
* @deprecated There is no replacement for this interface.
2724
*/
28-
@Deprecated
2925
@ThreadSafe
3026
public interface BufferProvider {
3127
/**

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.mongodb.internal.connection;
1818

19-
import com.mongodb.connection.BufferProvider;
2019
import org.bson.ByteBuf;
2120
import org.bson.io.OutputBuffer;
2221

@@ -31,7 +30,6 @@
3130
/**
3231
* <p>This class is not part of the public API and may be removed or changed at any time</p>
3332
*/
34-
@SuppressWarnings("deprecation")
3533
public class ByteBufferBsonOutput extends OutputBuffer {
3634

3735
private static final int MAX_SHIFT = 31;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.mongodb.connection.ClusterSettings;
2828
import com.mongodb.connection.ConnectionPoolSettings;
2929
import com.mongodb.connection.ServerSettings;
30-
import com.mongodb.connection.StreamFactory;
3130
import com.mongodb.event.ClusterListener;
3231
import com.mongodb.event.CommandListener;
3332
import com.mongodb.event.ServerListener;
@@ -56,7 +55,6 @@
5655
*
5756
* <p>This class is not part of the public API and may be removed or changed at any time</p>
5857
*/
59-
@SuppressWarnings("deprecation")
6058
public final class DefaultClusterFactory {
6159
private static final Logger LOGGER = Loggers.getLogger("client");
6260

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.mongodb.connection.ConnectionPoolSettings;
2727
import com.mongodb.connection.ServerId;
2828
import com.mongodb.connection.ServerSettings;
29-
import com.mongodb.connection.StreamFactory;
3029
import com.mongodb.event.CommandListener;
3130
import com.mongodb.event.ServerListener;
3231
import com.mongodb.internal.inject.SameObjectProvider;
@@ -41,7 +40,6 @@
4140
/**
4241
* <p>This class is not part of the public API and may be removed or changed at any time</p>
4342
*/
44-
@SuppressWarnings("deprecation")
4543
public class DefaultClusterableServerFactory implements ClusterableServerFactory {
4644
private final ServerSettings serverSettings;
4745
private final ConnectionPoolSettings connectionPoolSettings;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.mongodb.internal.connection;
1818

1919
import com.mongodb.RequestContext;
20-
import com.mongodb.connection.BufferProvider;
2120
import com.mongodb.connection.ConnectionDescription;
2221
import com.mongodb.connection.ServerDescription;
2322
import com.mongodb.internal.async.SingleResultCallback;
@@ -31,7 +30,6 @@
3130
/**
3231
* <p>This class is not part of the public API and may be removed or changed at any time</p>
3332
*/
34-
@SuppressWarnings("deprecation")
3533
public interface InternalConnection extends BufferProvider {
3634

3735
int NOT_INITIALIZED_GENERATION = -1;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
import com.mongodb.connection.ServerDescription;
4040
import com.mongodb.connection.ServerId;
4141
import com.mongodb.connection.ServerType;
42-
import com.mongodb.connection.Stream;
43-
import com.mongodb.connection.StreamFactory;
4442
import com.mongodb.event.CommandListener;
4543
import com.mongodb.internal.ResourceUtil;
4644
import com.mongodb.internal.VisibleForTesting;
@@ -94,7 +92,6 @@
9492
* <p>This class is not part of the public API and may be removed or changed at any time</p>
9593
*/
9694
@NotThreadSafe
97-
@SuppressWarnings("deprecation")
9895
public class InternalStreamConnection implements InternalConnection {
9996

10097
private static final Set<String> SECURITY_SENSITIVE_COMMANDS = new HashSet<>(asList(

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.mongodb.ServerApi;
2323
import com.mongodb.connection.ClusterConnectionMode;
2424
import com.mongodb.connection.ServerId;
25-
import com.mongodb.connection.StreamFactory;
2625
import com.mongodb.event.CommandListener;
2726
import com.mongodb.lang.Nullable;
2827
import com.mongodb.spi.dns.InetAddressResolver;
@@ -34,7 +33,6 @@
3433
import static com.mongodb.assertions.Assertions.notNull;
3534
import static com.mongodb.internal.connection.ClientMetadataHelper.createClientMetadataDocument;
3635

37-
@SuppressWarnings("deprecation")
3836
class InternalStreamConnectionFactory implements InternalConnectionFactory {
3937
private final ClusterConnectionMode clusterConnectionMode;
4038
private final boolean isMonitoringConnection;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.mongodb.connection.ConnectionPoolSettings;
2828
import com.mongodb.connection.ServerId;
2929
import com.mongodb.connection.ServerSettings;
30-
import com.mongodb.connection.StreamFactory;
3130
import com.mongodb.event.CommandListener;
3231
import com.mongodb.internal.inject.EmptyProvider;
3332
import com.mongodb.lang.Nullable;
@@ -41,7 +40,6 @@
4140
* <p>This class is not part of the public API and may be removed or changed at any time</p>
4241
*/
4342
@ThreadSafe
44-
@SuppressWarnings("deprecation")
4543
public class LoadBalancedClusterableServerFactory implements ClusterableServerFactory {
4644
private final ServerSettings serverSettings;
4745
private final ConnectionPoolSettings connectionPoolSettings;

0 commit comments

Comments
 (0)