Mercurial > hg > monetdb-java
changeset 702:b4e968e5bd74
Some improvements.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 08 Dec 2022 19:13:46 +0100 (2022-12-08) |
parents | f89882b07614 |
children | 1c9d4c2a6947 |
files | src/main/java/org/monetdb/jdbc/MonetConnection.java src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java |
diffstat | 2 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java @@ -2791,7 +2791,7 @@ public class MonetConnection /** * addLine adds a String of data to this object's data array. - * Note that an IndexOutOfBoundsException can be thrown when an + * Note that an ArrayIndexOutOfBoundsException can be thrown when an * attempt is made to add more than the original construction size * specified. * @@ -3257,7 +3257,7 @@ public class MonetConnection // right, some protocol violation, // skip the rest of the result error = "M0M10!" + error; - in.discardRemainder(); + in.discardRemainder(error); break; }
--- a/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java +++ b/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java @@ -15,10 +15,8 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; /** - * Read text from a character-input stream, buffering characters so as - * to provide a means for efficient reading of characters, arrays and - * lines. This class is based on the BufferedReader class, and provides - * extra functionality useful for MCL. + * Read text from a character-input stream, buffering characters so as to + * provide a means for efficient reading of characters, arrays and lines. * * The BufferedMCLReader is typically used as layer inbetween an * InputStream and a specific interpreter of the data. @@ -40,7 +38,7 @@ import java.io.UnsupportedEncodingExcept * @see org.monetdb.mcl.net.MapiSocket * @see org.monetdb.mcl.io.BufferedMCLWriter */ -public final class BufferedMCLReader /* extends BufferedReader */ { +public final class BufferedMCLReader { private final BufferedReader inner; private String current = null; @@ -112,16 +110,18 @@ public final class BufferedMCLReader /* * * @return a string containing error messages, or null if there aren't any * @throws IOException if an IO exception occurs while talking to the server - * - * TODO(Wouter): should probably not have to be synchronized. */ - - - final public synchronized String discardRemainder() throws IOException { + final public String discardRemainder() throws IOException { return discard(null); } - final public synchronized String discardRemainder(String error) throws IOException { + /** + * Discard the remainder of the response but collect any further error messages. + * + * @return a string containing error messages, or null if there aren't any + * @throws IOException if an IO exception occurs while talking to the server + */ + final public String discardRemainder(String error) throws IOException { final StringBuilder sb; if (error != null) { @@ -133,6 +133,14 @@ public final class BufferedMCLReader /* return discard(sb); } + /** + * Discard the remainder of the response but collect any further error messages. + * + * @return a string containing error messages, or null if there aren't any + * @throws IOException if an IO exception occurs while talking to the server + * + * TODO(Wouter): should probably not have to be synchronized. + */ final synchronized String discard(StringBuilder errmsgs) throws IOException { while (lineType != LineType.PROMPT) { advance();