Skip to content

Commit

Permalink
Improve resource shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
gabilang committed Aug 22, 2023
1 parent 095b040 commit c2cfb76
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public class JSONGenerator implements Closeable {

private static final int DEFAULT_DEPTH = 10;

private Writer writer;
private final Writer writer;

private boolean[] levelInit = new boolean[DEFAULT_DEPTH];

private int currentLevel;

private boolean fieldActive;

private static boolean[] escChars = new boolean[93];
private static final boolean[] escChars = new boolean[93];

static {
escChars['"'] = true;
Expand Down Expand Up @@ -272,8 +272,11 @@ public void flush() throws IOException {
this.writer.flush();
}

@Override
public void close() throws IOException {
this.writer.close();
if (this.writer != null) {
this.writer.close();
}
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit c2cfb76

Please sign in to comment.