Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv6 related NPE in ServiceInfoImpl.getHostAddresses() #245

Open
bubbleguuum opened this issue Nov 21, 2022 · 4 comments
Open

IPv6 related NPE in ServiceInfoImpl.getHostAddresses() #245

bubbleguuum opened this issue Nov 21, 2022 · 4 comments

Comments

@bubbleguuum
Copy link

bubbleguuum commented Nov 21, 2022

jmdns version: 3.5.6.

I've got a few automated crash reports with this stack trace, with getHostAddress() called in a ServiceListener.serviceResolved() callback:

Caused by: java.lang.NullPointerException
at javax.jmdns.impl.ServiceInfoImpl.getHostAddresses(ServiceInfoImpl.java:420)
at javax.jmdns.impl.ServiceInfoImpl.getHostAddress(ServiceInfoImpl.java:404)

looking at getHostAddresses():

 @Override
    public String[] getHostAddresses() {
        Inet4Address[] ip4Aaddresses = this.getInet4Addresses();
        Inet6Address[] ip6Aaddresses = this.getInet6Addresses();
        String[] names = new String[ip4Aaddresses.length + ip6Aaddresses.length];
        for (int i = 0; i < ip4Aaddresses.length; i++) {
            names[i] = ip4Aaddresses[i].getHostAddress();
        }
        for (int i = 0; i < ip6Aaddresses.length; i++) {
            names[i + ip4Aaddresses.length] = "[" + ip6Aaddresses[i].getHostAddress() + "]";    
        }
        return names;
    }

line 420 is:

names[i + ip4Aaddresses.length] = "[" + ip6Aaddresses[i].getHostAddress() + "]";    

The only possible thing null on that line is ip6Aaddresses[i].
So I suppose getInet6Addresses() can return an Inet6Address[] where some elements are null.

I have not checked if v3.5.8 would fix this issue but I doubt it.
Anyway, since my program does not make use of ipv6 at all, I worked-around this issue issue calling ServiceInfoImpl.getInet4Address().getHostAddress().
Still it would be nice to get the bottom line of that NPE.

@ViToni
Copy link
Contributor

ViToni commented Jan 29, 2024

Error is also present with v3.5.8.

@usnasoft
Copy link
Contributor

This issue is probably retated to issue "ipv6 #260"

@ViToni
Copy link
Contributor

ViToni commented Jan 29, 2024

It is not in my case as it happened on Java 8 which is not mentioned in the JDK bug.

@kaikreuzer
Copy link
Member

If anyone is able to reproduce/debug it and provide a PR, I'm happy to merge it and do a new patch release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants