Skip to content

Commit c832bde

Browse files
committed
Merge pull request #2922 from kfeuz/Issue2576
Fixes NPE when calling ip() on disconnected clients.
2 parents 6269e2c + 3f01414 commit c832bde

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

java/libraries/net/src/processing/net/Client.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class Client implements Runnable {
5151

5252
Thread thread;
5353
Socket socket;
54-
String ip;
5554
int port;
5655
String host;
5756

@@ -274,7 +273,10 @@ public boolean active() {
274273
* @brief Returns the IP address of the machine as a String
275274
*/
276275
public String ip() {
277-
return socket.getInetAddress().getHostAddress();
276+
if (socket != null){
277+
return socket.getInetAddress().getHostAddress();
278+
}
279+
return null;
278280
}
279281

280282

0 commit comments

Comments
 (0)