fix(java): avoid Java 11 HTTP fixture reuse (#10365)

This commit is contained in:
易良 2026-08-28 07:15:38 +00:00 committed by GitHub
parent 85399d7ad1
commit c1444bdc40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -261,11 +261,14 @@ class DaemonSessionClientTest {
CountDownLatch cancelReceived = new CountDownLatch(1);
server.createContext("/session/session-1/cancel", exchange -> {
cancelReceived.countDown();
exchange.getResponseHeaders().set("Connection", "close");
exchange.sendResponseHeaders(204, -1);
exchange.close();
});
server.createContext("/session/session-1/detach", noContent());
server.createContext("/session/session-2/detach", noContent());
server.createContext("/session/session-1/detach",
noContentAndCloseConnection());
server.createContext("/session/session-2/detach",
noContentAndCloseConnection());
try (DaemonClient daemon = newClient();
DaemonSessionClient first = daemon.createSession()) {
@ -2949,6 +2952,14 @@ class DaemonSessionClientTest {
};
}
private static HttpHandler noContentAndCloseConnection() {
return exchange -> {
exchange.getResponseHeaders().set("Connection", "close");
exchange.sendResponseHeaders(204, -1);
exchange.close();
};
}
private static void sendJson(HttpExchange exchange, int status, String body)
throws IOException {
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);