jdk/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java
changeset 34774 03b4e6dc367b
parent 34390 feb9879cd993
equal deleted inserted replaced
34764:f9bcdce2df26 34774:03b4e6dc367b
    36 public class StreamEncoder extends Writer
    36 public class StreamEncoder extends Writer
    37 {
    37 {
    38 
    38 
    39     private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192;
    39     private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192;
    40 
    40 
    41     private volatile boolean isOpen = true;
    41     private volatile boolean closed;
    42 
    42 
    43     private void ensureOpen() throws IOException {
    43     private void ensureOpen() throws IOException {
    44         if (!isOpen)
    44         if (closed)
    45             throw new IOException("Stream closed");
    45             throw new IOException("Stream closed");
    46     }
    46     }
    47 
    47 
    48     // Factories for java.io.OutputStreamWriter
    48     // Factories for java.io.OutputStreamWriter
    49     public static StreamEncoder forOutputStreamWriter(OutputStream out,
    49     public static StreamEncoder forOutputStreamWriter(OutputStream out,
   154         }
   154         }
   155     }
   155     }
   156 
   156 
   157     public void close() throws IOException {
   157     public void close() throws IOException {
   158         synchronized (lock) {
   158         synchronized (lock) {
   159             if (!isOpen)
   159             if (closed)
   160                 return;
   160                 return;
   161             implClose();
   161             implClose();
   162             isOpen = false;
   162             closed = true;
   163         }
   163         }
   164     }
   164     }
   165 
   165 
   166     private boolean isOpen() {
   166     private boolean isOpen() {
   167         return isOpen;
   167         return !closed;
   168     }
   168     }
   169 
   169 
   170 
   170 
   171     // -- Charset-based stream encoder impl --
   171     // -- Charset-based stream encoder impl --
   172 
   172