TagBuilder: Open OutputStreamWriter in try-with-resource

Change-Id: Ic0e23039b0aec6171f192234c6b1474cd32eadff
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2018-03-02 11:04:27 +09:00 committed by Matthias Sohn
parent a73f6c6009
commit cf489d36b9
1 changed files with 2 additions and 3 deletions

View File

@ -180,8 +180,8 @@ public void setMessage(final String newMessage) {
*/
public byte[] build() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
try {
try (OutputStreamWriter w = new OutputStreamWriter(os,
Constants.CHARSET)) {
w.write("object "); //$NON-NLS-1$
getObjectId().copyTo(w);
w.write('\n');
@ -203,7 +203,6 @@ public byte[] build() {
w.write('\n');
if (getMessage() != null)
w.write(getMessage());
w.close();
} catch (IOException err) {
// This should never occur, the only way to get it above is
// for the ByteArrayOutputStream to throw, but it doesn't.