Skip to content

Commit 8ec152c

Browse files
authored
Return Future from Provider#sendBinary(ByteBuffer, boolean) (#10462)
2 parents ee568a2 + d8b6bf3 commit 8ec152c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

core/src/main/java/jenkins/websocket/WebSocketSession.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ protected final Future<Void> sendBinary(ByteBuffer data) throws IOException {
108108
return handler.sendBinary(data);
109109
}
110110

111-
protected final void sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException {
112-
handler.sendBinary(partialByte, isLast);
111+
protected final Future<Void> sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException {
112+
return handler.sendBinary(partialByte, isLast);
113113
}
114114

115115
protected final Future<Void> sendText(String text) throws IOException {

websocket/jetty12-ee9/src/main/java/jenkins/websocket/Jetty12EE9Provider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ public Future<Void> sendBinary(ByteBuffer data) throws IOException {
9292
}
9393

9494
@Override
95-
public void sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException {
96-
session().getRemote().sendPartialBytes(partialByte, isLast);
95+
public Future<Void> sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException {
96+
CompletableFuture<Void> f = new CompletableFuture<>();
97+
session().getRemote().sendPartialBytes(partialByte, isLast, new WriteCallbackImpl(f));
98+
return f;
9799
}
98100

99101
@Override

websocket/spi/src/main/java/jenkins/websocket/Provider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ interface Handler {
6565

6666
Future<Void> sendBinary(ByteBuffer data) throws IOException;
6767

68-
void sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException;
68+
Future<Void> sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException;
6969

7070
Future<Void> sendText(String text) throws IOException;
7171

0 commit comments

Comments
 (0)