8313768: Reduce interaction with volatile field in j.u.l.StreamHandler
Reviewed-by: dfuchs, jpai
This commit is contained in:
parent
cd16158edb
commit
c822183e98
@ -231,6 +231,7 @@ public class StreamHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void publish0(LogRecord record) {
|
private void publish0(LogRecord record) {
|
||||||
if (!isLoggable(record)) {
|
if (!isLoggable(record)) {
|
||||||
return;
|
return;
|
||||||
@ -246,6 +247,7 @@ public class StreamHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Writer writer = this.writer;
|
||||||
if (!doneHeader) {
|
if (!doneHeader) {
|
||||||
writer.write(getFormatter().getHead(this));
|
writer.write(getFormatter().getHead(this));
|
||||||
doneHeader = true;
|
doneHeader = true;
|
||||||
@ -295,7 +297,9 @@ public class StreamHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flush0() {
|
private void flush0() {
|
||||||
|
Writer writer = this.writer;
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
try {
|
try {
|
||||||
writer.flush();
|
writer.flush();
|
||||||
@ -309,6 +313,7 @@ public class StreamHandler extends Handler {
|
|||||||
|
|
||||||
private void flushAndClose() throws SecurityException {
|
private void flushAndClose() throws SecurityException {
|
||||||
checkPermission();
|
checkPermission();
|
||||||
|
Writer writer = this.writer;
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
try {
|
try {
|
||||||
if (!doneHeader) {
|
if (!doneHeader) {
|
||||||
@ -323,8 +328,8 @@ public class StreamHandler extends Handler {
|
|||||||
// report the exception to any registered ErrorManager.
|
// report the exception to any registered ErrorManager.
|
||||||
reportError(null, ex, ErrorManager.CLOSE_FAILURE);
|
reportError(null, ex, ErrorManager.CLOSE_FAILURE);
|
||||||
}
|
}
|
||||||
writer = null;
|
|
||||||
output = null;
|
output = null;
|
||||||
|
this.writer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user