Skip to content

Commit

Permalink
Discoverer: Fix NPE when NetIf is not specified
Browse files Browse the repository at this point in the history
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
  • Loading branch information
holgerfriedrich committed Oct 28, 2023
1 parent ab1c7f4 commit afb6337
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/io/calimero/knxnetip/Discoverer.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -215,7 +216,7 @@ public NetworkInterface getNetworkInterface()

@Override
public String toString() {
return hostPort(local) + " (" + ni.getName() + ") <- " + response;
return hostPort(local) + (ni == null ? "" : " (" + ni.getName() + ")") + " <- " + response;
}

@Override
Expand All @@ -225,9 +226,10 @@ public boolean equals(final Object obj)
return true;
if (!(obj instanceof final Result<?> other))
return false;
return getNetworkInterface().equals(other.getNetworkInterface())
&& localEndpoint().equals(other.localEndpoint())
&& getResponse().equals(other.getResponse()) && remote.equals(other.remote);
return Objects.equals(getNetworkInterface(), other.getNetworkInterface())
&& Objects.equals(localEndpoint(), other.localEndpoint())
&& Objects.equals(getResponse(), other.getResponse())
&& Objects.equals(remote, other.remote);
}

@Override
Expand Down

0 comments on commit afb6337

Please sign in to comment.