Skip to content

Commit a5995e5

Browse files
committed
ONLY Fast-Path
1 parent 2cdf617 commit a5995e5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/java.base/share/classes/java/io/InputStreamReader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public int read(char[] cbuf, int off, int len) throws IOException {
183183
return sd.read(cbuf, off, len);
184184
}
185185

186+
@Override
187+
public String readAllAsString() throws IOException {
188+
return sd.readAllAsString();
189+
}
190+
186191
/**
187192
* Tells whether this stream is ready to be read. An InputStreamReader is
188193
* ready if its input buffer is not empty, or if bytes are available to be

src/java.base/share/classes/sun/nio/cs/StreamDecoder.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class StreamDecoder extends Reader {
4949
private static final int MIN_BYTE_BUFFER_SIZE = 32;
5050
private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192;
5151

52+
private volatile boolean opened;
5253
private volatile boolean closed;
5354

5455
private void ensureOpen() throws IOException {
@@ -116,6 +117,7 @@ public String getEncoding() {
116117
}
117118

118119
public int read() throws IOException {
120+
opened = true;
119121
return read0();
120122
}
121123

@@ -149,6 +151,7 @@ private int read0() throws IOException {
149151

150152
public int read(char[] cbuf, int offset, int length) throws IOException {
151153
synchronized (lock) {
154+
opened = true;
152155
int off = offset;
153156
int len = length;
154157

@@ -192,6 +195,21 @@ public int read(char[] cbuf, int offset, int length) throws IOException {
192195
}
193196
}
194197

198+
@Override
199+
public String readAllAsString() throws IOException {
200+
synchronized (lock) {
201+
ensureOpen();
202+
final String s = (in == null || opened) ? super.readAllAsString() : new String(in.readAllBytes(), cs);
203+
opened = true;
204+
return s;
205+
}
206+
}
207+
/*
208+
@Override
209+
public String readAllAsString() throws IOException {
210+
throw new RuntimeException();
211+
}
212+
*/
195213
public boolean ready() throws IOException {
196214
synchronized (lock) {
197215
ensureOpen();

0 commit comments

Comments
 (0)