src/share/classes/java/util/logging/StreamHandler.java
Print this page
@@ -71,14 +71,13 @@
* <p>
* @since 1.4
*/
public class StreamHandler extends Handler {
- private LogManager manager = LogManager.getLogManager();
private OutputStream output;
private boolean doneHeader;
- private Writer writer;
+ private volatile Writer writer;
// Private method to configure a StreamHandler from LogManager
// properties and/or default values as specified in the class
// javadoc.
private void configure() {
@@ -167,11 +166,12 @@
* @exception SecurityException if a security manager exists and if
* the caller does not have <tt>LoggingPermission("control")</tt>.
* @exception UnsupportedEncodingException if the named encoding is
* not supported.
*/
- public void setEncoding(String encoding)
+ @Override
+ public synchronized void setEncoding(String encoding)
throws SecurityException, java.io.UnsupportedEncodingException {
super.setEncoding(encoding);
if (output == null) {
return;
}
@@ -199,10 +199,11 @@
* written to the stream before the <tt>LogRecord</tt> is written.
*
* @param record description of the log event. A null record is
* silently ignored and is not published
*/
+ @Override
public synchronized void publish(LogRecord record) {
if (!isLoggable(record)) {
return;
}
String msg;
@@ -238,20 +239,22 @@
* <p>
* @param record a <tt>LogRecord</tt>
* @return true if the <tt>LogRecord</tt> would be logged.
*
*/
+ @Override
public boolean isLoggable(LogRecord record) {
if (writer == null || record == null) {
return false;
}
return super.isLoggable(record);
}
/**
* Flush any buffered messages.
*/
+ @Override
public synchronized void flush() {
if (writer != null) {
try {
writer.flush();
} catch (Exception ex) {
@@ -292,9 +295,10 @@
* "tail" string.
*
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
+ @Override
public synchronized void close() throws SecurityException {
flushAndClose();
}
}