Skip to content

Commit

Permalink
For whatever reason, onBinary is never called, so the client just h…
Browse files Browse the repository at this point in the history
…angs
  • Loading branch information
jglick committed Nov 8, 2024
1 parent 4084c62 commit 08e9e3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions cli/src/main/java/hudson/cli/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -367,14 +366,16 @@ public void close() throws IOException {
ws.set(wsb.buildAsync(URI.create(url.replaceFirst("^http", "ws") + "cli/ws"), new WebSocket.Listener() {
@Override
public CompletionStage<?> onBinary(WebSocket webSocket, ByteBuffer data, boolean last) {
var f = new CompletableFuture<Void>();
try {
connection.handle(new DataInputStream(new ByteArrayInputStream(data.array())));
f.complete(null);
} catch (IOException x) {
f.completeExceptionally(x);
LOGGER.log(Level.WARNING, null, x);
}
return f;
return null;
}
@Override
public void onError(WebSocket webSocket, Throwable error) {
LOGGER.log(Level.WARNING, null, error);
}
}).get());
connection.start(args);
Expand Down
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/cli/CLIActionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void encodingAndLocale() throws Exception {
assertEquals(0, new Launcher.LocalLauncher(StreamTaskListener.fromStderr()).launch().cmds(
"java", "-Dfile.encoding=ISO-8859-2", "-Duser.language=cs", "-Duser.country=CZ", "-jar", jar.getAbsolutePath(),
"-s", j.getURL().toString()./* just checking */replaceFirst("/$", ""), "test-diagnostic").
stdout(baos).stderr(System.err).join());
stdout(new TeeOutputStream(baos, System.out)).stderr(System.err).join());
assertEquals("encoding=ISO-8859-2 locale=cs_CZ", baos.toString(Charset.forName("ISO-8859-2")).trim());
// TODO test that stdout/stderr are in expected encoding (not true of -remoting mode!)
// -ssh mode does not pass client locale or encoding
Expand Down

0 comments on commit 08e9e3c

Please sign in to comment.