Thanks Anthony, Volker
On Wed, May 7, 2014 at 9:03 PM, Anthony Petrov <[email protected]> wrote: > Hi Volker, > > The fix looks fine to me, too. > > -- > best regards, > Anthony > > > On 5/5/2014 10:07 PM, Volker Simonis wrote: >> >> Hi, >> >> could you please review this tiny fix: >> >> http://cr.openjdk.java.net/~simonis/webrevs/8042416/ >> https://bugs.openjdk.java.net/browse/JDK-8042416 >> >> X11GraphicsEnvironment.isDisplayLocal() calls >> X11GraphicsEnvironment._isDisplayLocal() whihc in turn iterates over >> all IP addressees of the DISPLAY host and checks if one of them >> corresponds to the IP address of a local network interface: >> >> for (; interfaces.hasMoreElements();) { >> locals = interfaces.nextElement().getInetAddresses(); >> for (; locals.hasMoreElements();) { >> for (int i = 0; i < remAddr.length; i++) { >> if (locals.nextElement().equals(remAddr[i])) { >> return Boolean.TRUE; >> } >> } >> } >> } >> >> However it calls locals.nextElement() for each IP address of the >> DISPLAY host so if the DISPLAY host has more IP addresses than one of >> the local network interfaces, the check will unexpectedly throw a >> NoSuchElementException. >> >> The solution is simple - just compare every IP-Address of the DISPLAY >> host against each IP-address of every network interface like so: >> >> for (; interfaces.hasMoreElements();) { >> locals = interfaces.nextElement().getInetAddresses(); >> for (; locals.hasMoreElements();) { >> final InetAddress localAddr = locals.nextElement(); >> for (int i = 0; i < remAddr.length; i++) { >> if (localsAddr.equals(remAddr[i])) { >> return Boolean.TRUE; >> } >> } >> } >> } >> >> Thank you and best regards, >> Volker >> >> >> PS: Notice that if we ever want to downport this to jdk8 we need an >> additional cast like so: >> >> final InetAddress localAddr = (InetAddress)locals.nextElement(); >> >> unless we also downport "8039642: Fix raw and unchecked warnings in >> sun.awt.*" before this change. >> >
