Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 226f8c6

Browse files
committed
Unfixed #86
This is an issue with sun http server, not simplehttpserver
1 parent 16b5abe commit 226f8c6

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpServerImpl.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,9 @@ public synchronized final HttpContext createContext(final String context, final
157157
handler.handle(exchange);
158158
};
159159

160+
final HttpContext hc = server.createContext(ct);
160161

161-
for(final HttpContext httpContext : contexts.keySet())
162-
if(httpContext.getPath().equals(ct))
163-
throw new IllegalArgumentException("The context '" + ct + "' is already occupied");
164-
165-
final HttpContext hc = server.createContext(ct,wrapper);
162+
hc.setHandler(wrapper);
166163
contexts.put(hc,handler);
167164

168165
if(authenticator != null)

src/test/java/simplehttpserver/SimpleHttpServerContextTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ public final void createSlashedContext() throws IOException{
135135
}
136136

137137

138-
@Test(expected = IllegalArgumentException.class)
138+
@Test// (expected = IllegalArgumentException.class)
139139
public final void createDuplicateContext() throws IOException{
140140
final SimpleHttpServer server = SimpleHttpServer.create();
141-
final String context = server.getRandomContext();
141+
final String context = "duplicate";
142142

143143
server.createContext(context);
144144
server.createContext(context,HttpExchange::close);

0 commit comments

Comments
 (0)