Skip to content

Commit ec59478

Browse files
committed
Fix test on macos 17
1 parent b68249a commit ec59478

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/websocket/WebSocketClientTest.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,11 @@ public void onError(final Throwable ex) {
246246
}
247247
}
248248

249-
/**
250-
* Client enforces maxMessageSize: server sends a too-large message → client closes with 1009.
251-
*
252-
* We use a dedicated /too-big endpoint that proactively sends a large text frame so the
253-
* client-side size check is the only reason for closure – no races with server-initiated CLOSE.
254-
*/
255249
@Test
256250
void max_message_1009() throws Exception {
257251
final CountDownLatch done = new CountDownLatch(1);
252+
final AtomicReference<Integer> codeRef = new AtomicReference<>();
253+
final AtomicReference<Throwable> errorRef = new AtomicReference<>();
258254
final int maxMessage = 2048; // 2 KiB
259255

260256
try (final CloseableWebSocketClient client = newClient()) {
@@ -277,23 +273,28 @@ public void onText(final CharBuffer text, final boolean last) {
277273

278274
@Override
279275
public void onClose(final int code, final String reason) {
280-
assertEquals(1009, code);
276+
codeRef.set(code);
281277
done.countDown();
282278
}
283279

284280
@Override
285281
public void onError(final Throwable ex) {
282+
errorRef.set(ex);
286283
done.countDown();
287284
}
288285
}, cfg, null);
289286

290287
assertTrue(done.await(10, TimeUnit.SECONDS), "timeout waiting for 1009 close");
288+
289+
final Throwable error = errorRef.get();
290+
if (error != null) {
291+
Assertions.fail("WebSocket error: " + error.getMessage(), error);
292+
}
293+
294+
assertEquals(Integer.valueOf(1009), codeRef.get(), "expected 1009 close code");
291295
}
292296
}
293297

294-
/**
295-
* Server drops TCP without sending CLOSE → client reports abnormal closure 1006.
296-
*/
297298
@Test
298299
void abnormal_close_1006() throws Exception {
299300
final CountDownLatch done = new CountDownLatch(1);
@@ -398,9 +399,6 @@ public void configure(final WebSocketServletFactory factory) {
398399
}
399400
}
400401

401-
/**
402-
* Sends a single oversized text message as soon as the WebSocket is established.
403-
*/
404402
public static final class TooBigSocket extends WebSocketAdapter {
405403
@Override
406404
public void onWebSocketConnect(final Session sess) {

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@
521521
<title>Apache HttpClient SSE</title>
522522
<packages>org.apache.hc.client5.http.sse*</packages>
523523
</group>
524+
<group>
525+
<title>Apache HttpClient SSE</title>
526+
<packages>org.apache.hc.client5.http.websocket*</packages>
527+
</group>
524528

525529
</groups>
526530
</configuration>

0 commit comments

Comments
 (0)