Skip to content

Commit 9c8785c

Browse files
committed
merge from release19.2 (through 64657)
SVN r64659 |2019-10-23 22:00:57 +0000
1 parent c0be087 commit 9c8785c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

java/src/org/labkey/remoteapi/Command.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@
2828
import org.json.simple.JSONValue;
2929

3030
import java.io.BufferedReader;
31+
import java.io.ByteArrayInputStream;
3132
import java.io.Closeable;
3233
import java.io.IOException;
3334
import java.io.InputStream;
3435
import java.io.InputStreamReader;
3536
import java.io.Reader;
37+
import java.io.StringReader;
3638
import java.net.URI;
3739
import java.net.URISyntaxException;
3840
import java.nio.charset.StandardCharsets;
@@ -274,11 +276,23 @@ public Long getContentLength()
274276

275277
public InputStream getInputStream() throws IOException
276278
{
279+
if (_responseText != null)
280+
{
281+
// We've already consumed the input stream and stashed the result, so use that instead of going back
282+
// to the stream
283+
return new ByteArrayInputStream(_responseText.getBytes(StandardCharsets.UTF_8));
284+
}
277285
return _httpResponse.getEntity().getContent();
278286
}
279287

280288
public Reader getReader() throws IOException
281289
{
290+
if (_responseText != null)
291+
{
292+
// We've already consumed the input stream and stashed the result, so use that instead of going back
293+
// to the stream
294+
return new StringReader(_responseText);
295+
}
282296
return new BufferedReader(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8));
283297
}
284298

@@ -295,6 +309,7 @@ public String getText() throws IOException
295309
}
296310

297311
// Caller is responsible for closing the response
312+
@Override
298313
public void close() throws IOException
299314
{
300315
_httpResponse.close();

0 commit comments

Comments
 (0)