Skip to content

Commit c822183

Browse files
Sergey Tsypanovjaikiran
authored andcommitted
8313768: Reduce interaction with volatile field in j.u.l.StreamHandler
Reviewed-by: dfuchs, jpai
1 parent cd16158 commit c822183

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/java.logging/share/classes/java/util/logging/StreamHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public void publish(LogRecord record) {
231231
}
232232
}
233233
}
234+
234235
private void publish0(LogRecord record) {
235236
if (!isLoggable(record)) {
236237
return;
@@ -246,6 +247,7 @@ private void publish0(LogRecord record) {
246247
}
247248

248249
try {
250+
Writer writer = this.writer;
249251
if (!doneHeader) {
250252
writer.write(getFormatter().getHead(this));
251253
doneHeader = true;
@@ -295,7 +297,9 @@ public void flush() {
295297
}
296298
}
297299
}
300+
298301
private void flush0() {
302+
Writer writer = this.writer;
299303
if (writer != null) {
300304
try {
301305
writer.flush();
@@ -309,6 +313,7 @@ private void flush0() {
309313

310314
private void flushAndClose() throws SecurityException {
311315
checkPermission();
316+
Writer writer = this.writer;
312317
if (writer != null) {
313318
try {
314319
if (!doneHeader) {
@@ -323,8 +328,8 @@ private void flushAndClose() throws SecurityException {
323328
// report the exception to any registered ErrorManager.
324329
reportError(null, ex, ErrorManager.CLOSE_FAILURE);
325330
}
326-
writer = null;
327331
output = null;
332+
this.writer = null;
328333
}
329334
}
330335

0 commit comments

Comments
 (0)