Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,11 @@ private DynamicMessage parseJsonStartResponse(byte[] data) throws IOException {
DynamicMessage.Builder endBuilder = DynamicMessage.newBuilder(endDesc);
Descriptors.FieldDescriptor exitCodeField = endDesc.findFieldByName("exit_code");
JsonNode exitCodeNode = endNode.path("exitCode");
if (exitCodeNode.canConvertToInt()) {
boolean hasExitCode = exitCodeNode.canConvertToInt();
if (hasExitCode) {
endBuilder.setField(exitCodeField, exitCodeNode.intValue());
event.setField(processEventDesc.findFieldByName("end"), endBuilder.build());
}
event.setField(processEventDesc.findFieldByName("end"), endBuilder.build());
}

if (!event.getAllFields().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void jsonCodecReturnsEmptyOutputsWhenOnlyEndPresent() throws Exception {
}

@Test
void jsonCodecPreservesZeroExitCode() throws Exception {
void jsonCodecPreservesSuccessfulExitCode() throws Exception {
E2bEnvdProcessClient client = new E2bEnvdProcessClient(options(E2bCodec.JSON));
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
Expand All @@ -158,6 +158,17 @@ void jsonCodecPreservesZeroExitCode() throws Exception {
assertEquals(0, exit);
}

@Test
void jsonCodecTreatsEmptyEndEventAsSuccessfulExit() throws Exception {
E2bEnvdProcessClient client = new E2bEnvdProcessClient(options(E2bCodec.JSON));
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
int exit =
drainStartStream(client, connectFrame("{\"event\":{\"end\":{}}}"), stdout, stderr);

assertEquals(0, exit);
}

private static DynamicMessage dataResponse(
E2bEnvdProcessClient client, String stdout, String stderr) {
Descriptors.FileDescriptor fd = client.fileDescriptor();
Expand Down
Loading