Duplicate contexts do not throw IllegalArgumentException [EXTERNAL ISSUE]
Katsute opened this issue · 2 comments
Prerequisites
If all checks are not passed then the issue will be closed
- I have checked that no other similar issue already exists
Operating System: Operating system name and version
Windows 10
Release Version: Release version or branch where the issue occurred
03.05.06
Issue
Explain your issue. Add any screenshots here
Duplicate contexts do not throw IllegalArgumentException.
Issue is caused by HttpServer; this is not a SimpleHttpServer issue.
Expected Behavior
Explain what was supposed to happen
Duplicate contexts should throw IllegalArgumentException.
Steps To Reproduce
Explain how and/or when the error occurred
Use createContext on same context using HttpServer.
Multiple tests have been run against the #create method in the sun http server library; but the illargs exception is only thrown for specific contexts, not all. This is a dependency issue and can not be resolved by SimpleHttpServer
According to the source code an IllegalArgumentException is never thrown for duplicate contexts. The documentation on this method is invalid.
sun.net.httpserver.ServerImpl
...
public synchronized HttpContextImpl createContext (String path, HttpHandler handler) {
if (handler == null || path == null) {
throw new NullPointerException ("null handler, or path parameter");
}
HttpContextImpl context = new HttpContextImpl (protocol, path, handler, this);
contexts.add (context);
logger.log (Level.DEBUG, "context created: " + path);
return context;
}
...sun.net.httpserver.HttpContextImpl
...
HttpContextImpl (String protocol, String path, HttpHandler cb, ServerImpl server) {
if (path == null || protocol == null || path.length() < 1 || path.charAt(0) != '/') {
throw new IllegalArgumentException ("Illegal value for path or protocol");
}
this.protocol = protocol.toLowerCase();
this.path = path;
if (!this.protocol.equals ("http") && !this.protocol.equals ("https")) {
throw new IllegalArgumentException ("Illegal value for protocol");
}
this.handler = cb;
this.server = server;
authfilter = new AuthFilter(null);
sfilters.add (authfilter);
}
...