Thank you for sharing the unit test results - you were right, the creation of a URL almost nothing happens. Comparison causes problems:
Assert.assertThat(url, equalTo(new URL("http://aa")));
There seems to be a REALLY call to http://aa ! It seems that only with "localhost" is this fast:
Assert.assertThat(url, equalTo(new URL("http://localhost")));
The solution would be to compare the String representation:
Assert.assertThat(url.toExternalForm(), equalTo(new URL("http://aa").toExternalForm()));
source share