Skip to content

Commit

Permalink
fixes usage of outputStreams
Browse files Browse the repository at this point in the history
  • Loading branch information
awildturtok committed Jan 22, 2024
1 parent 4d3d99b commit 1b38713
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.bakdata.conquery.models.messages.network.specific;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;

import com.bakdata.conquery.io.cps.CPSType;
Expand Down Expand Up @@ -58,15 +55,11 @@ public static ForwardToWorker create(WorkerId worker, WorkerMessage message, Obj

@SneakyThrows(IOException.class)
private static byte[] serializeMessage(WorkerMessage message, ObjectWriter writer) {
try (OutputStream outputStream = new ByteArrayOutputStream()) {
writer.writeValue(outputStream, message);
}

return new ByteArrayOutputStream().toByteArray();
return writer.writeValueAsBytes(message);
}

private static WorkerMessage deserializeMessage(byte[] messageRaw, ObjectMapper mapper) throws java.io.IOException {
return mapper.readerFor(WorkerMessage.class).readValue(new ByteArrayInputStream(messageRaw));
return mapper.readerFor(WorkerMessage.class).readValue(messageRaw);
}

@Override
Expand Down

0 comments on commit 1b38713

Please sign in to comment.