On Fri, 2 Jul 2021 11:56:04 GMT, Julia Boes <jb...@openjdk.org> wrote:
> `com.sun.net.httpserver.HttpServer::createContext` specifies > `IllegalArgumentException` to be thrown if a context already exists for the > path provided. The implementation class`sun.net.httpserver.ServerImpl` does > not comply with this, which is fixed by this change. > > Testing: Tier 1-3 all clear. Changes requested by dfuchs (Reviewer). src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java line 44: > 42: } > 43: > 44: synchronized boolean contains(HttpContextImpl ctx) { You can remove synchronized here since you're calling a synchronized method. test/jdk/com/sun/net/httpserver/HttpContextTest.java line 67: > 65: assertThrows(IAE, () -> server.createContext(path, new > Handler())); > 66: server.removeContext(path); > 67: assertThrows(IAE, () -> server.removeContext(path)); Can you add some test to double check that having a context named "/foo/" doesn't prevent you from adding a subcontext "/foo/bar/"? Same for "/foo" and "/foobar". ------------- PR: https://git.openjdk.java.net/jdk/pull/4665