Permalink
Browse files

fix: correct edge cases for setCharacterStream(int, Reader)

ReaderInputStream behaved wrong (e.g. might return 0 instead of -1) at the end of the input in certain cases.
  • Loading branch information...
vlsi committed Feb 12, 2017
1 parent 989b4d2 commit f1190d8c2eb1c506616e2298aabad211ba3bdb0a
@@ -112,7 +112,7 @@ public int read() throws IOException {
int res = 0;
while (res != -1) {
res = read(oneByte);
if (res != 0) {
if (res > 0) {
return oneByte[0];
}
}
@@ -148,6 +148,9 @@ public int read(byte b[], int off, int len) throws IOException {
}
advance();
}
if (endOfInput && !bbuf.hasRemaining()) {
return -1;
}
return totalRead;
}
@@ -16,6 +16,7 @@
import org.postgresql.test.util.LruCacheTest;
import org.postgresql.test.util.ServerVersionParseTest;
import org.postgresql.test.util.ServerVersionTest;
import org.postgresql.util.ReaderInputStreamTest;
import junit.framework.JUnit4TestAdapter;
import junit.framework.TestSuite;
@@ -53,6 +54,7 @@ public static TestSuite suite() throws Exception {
suite.addTest(new JUnit4TestAdapter(ColumnSanitiserDisabledTest.class));
suite.addTest(new JUnit4TestAdapter(ColumnSanitiserEnabledTest.class));
suite.addTest(new JUnit4TestAdapter(LruCacheTest.class));
suite.addTest(new JUnit4TestAdapter(ReaderInputStreamTest.class));
suite.addTest(new JUnit4TestAdapter(ServerVersionParseTest.class));
suite.addTest(new JUnit4TestAdapter(ServerVersionTest.class));

0 comments on commit f1190d8

Please sign in to comment.