Skip to content

Commit 481e793

Browse files
authored
Deprecate SocketAddress-related methods (#1188)
* ServerAddress#getSocketAddress * ServerAddress#getSocketAddresses * UnixServerAddress#getUnixSocketAddress JAVA-4940
1 parent d08adff commit 481e793

File tree

8 files changed

+15
-0
lines changed

8 files changed

+15
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ public int getPort() {
188188
* Gets the underlying socket address
189189
*
190190
* @return socket address
191+
* @deprecated Prefer {@link InetAddress#getByName(String)}
191192
*/
193+
@Deprecated
192194
public InetSocketAddress getSocketAddress() {
193195
try {
194196
return new InetSocketAddress(InetAddress.getByName(host), port);
@@ -203,7 +205,9 @@ public InetSocketAddress getSocketAddress() {
203205
* @return array of socket addresses
204206
*
205207
* @since 3.9
208+
* @deprecated Prefer {@link InetAddress#getAllByName(String)}
206209
*/
210+
@Deprecated
207211
public List<InetSocketAddress> getSocketAddresses() {
208212
try {
209213
InetAddress[] inetAddresses = InetAddress.getAllByName(host);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ public UnixServerAddress(final String path) {
4444
isTrueArgument("The path must end in .sock", path.endsWith(".sock"));
4545
}
4646

47+
@SuppressWarnings("deprecation")
48+
@Deprecated
4749
@Override
4850
public InetSocketAddress getSocketAddress() {
4951
throw new UnsupportedOperationException("Cannot return a InetSocketAddress from a UnixServerAddress");
5052
}
5153

5254
/**
5355
* @return the SocketAddress for the MongoD unix domain socket.
56+
* @deprecated Prefer {@link UnixSocketAddress#UnixSocketAddress(String)}
5457
*/
58+
@Deprecated
5559
public SocketAddress getUnixSocketAddress() {
5660
return new UnixSocketAddress(getHost());
5761
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ public boolean supportsAdditionalTimeout() {
197197
return true;
198198
}
199199

200+
@SuppressWarnings("deprecation")
200201
@Override
201202
public void openAsync(final AsyncCompletionHandler<Void> handler) {
202203
isTrue("unopened", getChannel() == null);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public void open() throws IOException {
160160
handler.get();
161161
}
162162

163+
@SuppressWarnings("deprecation")
163164
@Override
164165
public void openAsync(final AsyncCompletionHandler<Void> handler) {
165166
Queue<SocketAddress> socketAddressQueue;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public AsynchronousSocketChannelStream(final ServerAddress serverAddress, final
5454
this.group = group;
5555
}
5656

57+
@SuppressWarnings("deprecation")
5758
@Override
5859
public void openAsync(final AsyncCompletionHandler<Void> handler) {
5960
isTrue("unopened", getChannel() == null);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ final class ServerAddressWithResolver extends ServerAddress {
5151
this.resolver = inetAddressResolver == null ? DEFAULT_INET_ADDRESS_RESOLVER : inetAddressResolver;
5252
}
5353

54+
@SuppressWarnings("deprecation")
5455
@Override
5556
public InetSocketAddress getSocketAddress() {
5657
if (resolver == null) {
@@ -60,6 +61,7 @@ public InetSocketAddress getSocketAddress() {
6061
return getSocketAddresses().get(0);
6162
}
6263

64+
@SuppressWarnings("deprecation")
6365
@Override
6466
public List<InetSocketAddress> getSocketAddresses() {
6567
if (resolver == null) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void open() {
7474
}
7575
}
7676

77+
@SuppressWarnings("deprecation")
7778
protected Socket initializeSocket() throws IOException {
7879
Iterator<InetSocketAddress> inetSocketAddresses = address.getSocketAddresses().iterator();
7980
while (inetSocketAddresses.hasNext()) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public UnixSocketChannelStream(final UnixServerAddress address, final SocketSett
3939
this.address = address;
4040
}
4141

42+
@SuppressWarnings("deprecation")
4243
@Override
4344
protected Socket initializeSocket() throws IOException {
4445
return UnixSocketChannel.open((UnixSocketAddress) address.getUnixSocketAddress()).socket();

0 commit comments

Comments
 (0)