Skip to content

Commit 781c8c8

Browse files
authored
Use try-with-resources when serializing variable in VariableInstanceDataResource (#4240)
1 parent 5a1a2ef commit 781c8c8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/VariableInstanceDataResource.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public byte[] getVariableData(@ApiParam(name = "varInstanceId") @PathVariable("v
7272
response.setContentType("application/octet-stream");
7373

7474
} else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
75-
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
76-
ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
77-
outputStream.writeObject(variable.getValue());
78-
outputStream.close();
79-
result = buffer.toByteArray();
80-
response.setContentType("application/x-java-serialized-object");
75+
try (ByteArrayOutputStream buffer = new ByteArrayOutputStream();
76+
ObjectOutputStream outputStream = new ObjectOutputStream(buffer)) {
77+
outputStream.writeObject(variable.getValue());
78+
result = buffer.toByteArray();
79+
response.setContentType("application/x-java-serialized-object");
80+
}
8181

8282
} else {
8383
throw new FlowableObjectNotFoundException("The variable does not have a binary data stream.", null);

0 commit comments

Comments
 (0)