Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ public Future<Void> send(String str, String enc, int port, String host) {

@Override
public SocketAddress localAddress() {
return context.owner().transport().convert(channel.localAddress());
InetSocketAddress localAddress = channel.localAddress();
return localAddress != null ? context.owner().transport().convert(localAddress) : null;
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions vertx-core/src/test/java/io/vertx/tests/datagram/DatagramTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,14 @@ public void start(Promise<Void> startPromise) {
}));
await();
}

@Test
public void shouldNotThrowWhenReadingLocalAddressBeforeBind() {
peer1 = vertx.createDatagramSocket(new DatagramSocketOptions());
try {
peer1.localAddress();
} catch (Exception e) {
fail(e);
}
}
}
Loading