correctly close ByteBuffer in try resources (#1788)

Signed-off-by: olivier lamy <olamy@apache.org>
This commit is contained in:
Olivier Lamy 2018-08-15 09:10:47 +10:00 committed by GitHub
parent df41bfb96a
commit db24f4985f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -164,10 +164,9 @@ public class PipelineStepImpl extends BluePipelineStep {
return null;
}
msg = msg + "\n";
ByteBuffer byteBuffer = new ByteBuffer();
try {
try (ByteBuffer byteBuffer = new ByteBuffer();) {
byteBuffer.write(msg.getBytes("UTF-8"));
byteBuffer.close();
return new LogResource(new AnnotatedLargeText(byteBuffer, Charset.forName("UTF-8"),true, null));
} catch (IOException e) {
throw new ServiceException.UnexpectedErrorException(e.getMessage());