Skip to content

Commit

Permalink
8313768: Reduce interaction with volatile field in j.u.l.StreamHandler
Browse files Browse the repository at this point in the history
Reviewed-by: dfuchs, jpai
  • Loading branch information
Sergey Tsypanov authored and jaikiran committed Aug 10, 2023
1 parent cd16158 commit c822183
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public void publish(LogRecord record) {
}
}
}

private void publish0(LogRecord record) {
if (!isLoggable(record)) {
return;
Expand All @@ -246,6 +247,7 @@ private void publish0(LogRecord record) {
}

try {
Writer writer = this.writer;
if (!doneHeader) {
writer.write(getFormatter().getHead(this));
doneHeader = true;
Expand Down Expand Up @@ -295,7 +297,9 @@ public void flush() {
}
}
}

private void flush0() {
Writer writer = this.writer;
if (writer != null) {
try {
writer.flush();
Expand All @@ -309,6 +313,7 @@ private void flush0() {

private void flushAndClose() throws SecurityException {
checkPermission();
Writer writer = this.writer;
if (writer != null) {
try {
if (!doneHeader) {
Expand All @@ -323,8 +328,8 @@ private void flushAndClose() throws SecurityException {
// report the exception to any registered ErrorManager.
reportError(null, ex, ErrorManager.CLOSE_FAILURE);
}
writer = null;
output = null;
this.writer = null;
}
}

Expand Down

1 comment on commit c822183

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.