Skip to content

LocalAddressUtils#getMostLikelyLocalInetAddresses fails if list contains loopback#1842

Merged
matthiasblaesing merged 1 commit intoapache:masterfrom
matthiasblaesing:remove_loopback_arrays
Jan 4, 2020
Merged

LocalAddressUtils#getMostLikelyLocalInetAddresses fails if list contains loopback#1842
matthiasblaesing merged 1 commit intoapache:masterfrom
matthiasblaesing:remove_loopback_arrays

Conversation

@matthiasblaesing
Copy link
Contributor

The problem is located in IpAddressUtils#removeLoopback. The method
expects, that the supplied list provides an Iterator, that supports
remove.

The list returned by Arrays#asList does not provide that, it is just a
view on the array.

…ins loopback

The problem is located in IpAddressUtils#removeLoopback. The method
expects, that the supplied list provides an Iterator, that supports
remove.

The list returned by Arrays#asList does not provide that, it is just a
view on the array.
@matthiasblaesing
Copy link
Contributor Author

@lbruun could you please have a look at this? #1821 enabled tests on mac OS and this resulted in a test failure:

https://travis-ci.org/apache/netbeans/jobs/632614833#L2670

WARNING: Error when executing PAC script function FindProxyForURL : 
java.lang.UnsupportedOperationException: remove
	at java.base/java.util.Iterator.remove(Iterator.java:102)
	at org.netbeans.core.network.utils.IpAddressUtils.removeLoopback(IpAddressUtils.java:442)
	at org.netbeans.core.network.utils.LocalAddressUtils.getMostLikelyLocalInetAddresses(LocalAddressUtils.java:440)
	at org.netbeans.core.network.utils.LocalAddressUtils.getMostLikelyLocalInetAddress(LocalAddressUtils.java:499)
	at org.netbeans.core.network.proxy.pac.impl.NbPacHelperMethods.myIpAddress(NbPacHelperMethods.java:126)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$110$590$\^eval\_.L:1#L:26(<eval>:27)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$96$809AA$\^eval\_.FindProxyForURL(<eval>:101)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:659)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:202)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:393)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:197)
	at org.netbeans.core.network.proxy.pac.impl.NbPacScriptEvaluator$PacScriptEngine.findProxyForURL(NbPacScriptEvaluator.java:548)
	at org.netbeans.core.network.proxy.pac.impl.NbPacScriptEvaluator.findProxyForURL(NbPacScriptEvaluator.java:221)
	at org.netbeans.core.network.proxy.pac.PacEngineTest.testPacFile2(PacEngineTest.java:103)
	at org.netbeans.core.network.proxy.pac.PacEngineTest.testEngine(PacEngineTest.java:76)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:77)
	at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:460)
	at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:386)
	at java.base/java.lang.Thread.run(Thread.java:834)

@lbruun
Copy link
Contributor

lbruun commented Jan 4, 2020

My bad.
@matthiasblaesing. Your fix is spot on. Thx.

@matthiasblaesing
Copy link
Contributor Author

@lbruun thanks for checking.

@matthiasblaesing matthiasblaesing merged commit 993c2c2 into apache:master Jan 4, 2020
@matthiasblaesing matthiasblaesing deleted the remove_loopback_arrays branch January 4, 2020 21:39
@junichi11 junichi11 added this to the 11.3 milestone Jan 5, 2020
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

Successfully merging this pull request may close these issues.

3 participants