/** *Createsasocketconnection,whichinternallytriggersproxyselectionforthetarget *address.Thetesthasbeenconfiguredtousea{@linkSchemeStrippedProxySelectorProxySelector} *whichthrowsa{@linkIllegalArgumentException}.ThistestthenverifiesthatthisIAEgetswrapped *by{@codejava.net.SocksSocketImpl}intoan{@linkIOException}beforebeingthrown * *@throwsException
*/
@Test publicvoid testIOEOnProxySelection() throws Exception { finalint backlog = -1; finalint port = 0; try (ServerSocket ss = new ServerSocket(port, backlog, InetAddress.getLoopbackAddress());
Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort());
Socket s2 = ss.accept()) { Assert.fail("IOException was expected to be thrown, but wasn't");
} catch (IOException ioe) { // expected // now verify the IOE was thrown for the correct expected reason if (!(ioe.getCause() instanceof IllegalArgumentException)) { // rethrow this so that the test output failure will capture the entire/real // cause in its stacktrace throw ioe;
}
}
}
@Override public List<Proxy> select(final URI uri) {
System.out.println("Proxy selection for " + uri); final URI schemeStrippedURI; try { // strip the scheme and pass the rest
schemeStrippedURI = new URI(null, uri.getHost(), uri.getPath(), null);
} catch (URISyntaxException e) { thrownew RuntimeException(e);
}
System.out.println("Scheme stripped URI " + schemeStrippedURI + " is being used to select a proxy"); returnsuper.select(schemeStrippedURI);
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-06-09)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.