Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/java/net/openid/appauth/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ private Utils() {
* Read a string from an input stream.
*/
public static String readInputStream(InputStream in) throws IOException {
if (in == null) {
throw new IOException("Input stream must not be null");
}

BufferedReader br = new BufferedReader(new InputStreamReader(in));
char[] buffer = new char[INITIAL_READ_BUFFER_SIZE];
StringBuilder sb = new StringBuilder();
Expand Down
5 changes: 5 additions & 0 deletions library/javatests/net/openid/appauth/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public void testReadInputStream() throws Exception {
InputStream in = new ByteArrayInputStream(TEST_STRING.getBytes());
assertEquals(TEST_STRING, Utils.readInputStream(in));
}

@Test(expected = IOException.class)
public void testReadInputStream_throw() throws Exception{
Utils.readInputStream(null);
}
}