Mercurial > hg > monetdb-java
changeset 403:1d10d4759108 embedded
Java 8 vs 9 fixes
author | Pedro Ferreira <pedro.ferreira@monetdbsolutions.com> |
---|---|
date | Mon, 04 Jan 2021 10:10:11 +0100 (2021-01-04) |
parents | 57663e5924f4 |
children | 122773971f50 |
files | src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java src/main/java/nl/cwi/monetdb/mcl/connection/mapi/AbstractSocket.java src/main/java/nl/cwi/monetdb/mcl/connection/mapi/OldMapiSocket.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java |
diffstat | 6 files changed, 22 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java @@ -19,6 +19,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.net.URL; +import java.nio.Buffer; import java.nio.CharBuffer; import java.sql.*; import java.text.SimpleDateFormat; @@ -1454,7 +1455,7 @@ public class MonetPreparedStatement e.getMessage(), "M1M25"); } // We have to rewind the buffer, because otherwise toString() returns "". - buf.rewind(); + ((Buffer)buf).rewind(); setString(parameterIndex, buf.toString()); }
--- a/src/main/java/nl/cwi/monetdb/mcl/connection/mapi/AbstractSocket.java +++ b/src/main/java/nl/cwi/monetdb/mcl/connection/mapi/AbstractSocket.java @@ -158,7 +158,7 @@ public abstract class AbstractSocket imp if(read == 0) { throw new IOException("The server has reached EOF!"); } - this.stringsDecoded.clear(); + ((Buffer)this.stringsDecoded).clear(); this.utf8Decoder.reset(); this.utf8Decoder.decode(this.bufferIn, this.stringsDecoded,true); this.utf8Decoder.flush(this.stringsDecoded); @@ -173,7 +173,7 @@ public abstract class AbstractSocket imp * @throws IOException If an error in the underlying connection happened */ public CharBuffer readLine(CharBuffer lineBuffer) throws IOException { - lineBuffer.clear(); + ((Buffer)lineBuffer).clear(); boolean found = false; char[] sourceArray = this.stringsDecoded.array(); int sourcePosition = this.stringsDecoded.position(); @@ -184,7 +184,7 @@ public abstract class AbstractSocket imp while(!found) { if(sourcePosition >= sourceLimit) { - this.stringsDecoded.position(sourcePosition); + ((Buffer)this.stringsDecoded).position(sourcePosition); this.readToInputBuffer(); sourceArray = this.stringsDecoded.array(); sourcePosition = 0; @@ -202,8 +202,8 @@ public abstract class AbstractSocket imp destinationArray[destinationPosition++] = c; } } - this.stringsDecoded.position(sourcePosition); - lineBuffer.position(destinationPosition); + ((Buffer)this.stringsDecoded).position(sourcePosition); + ((Buffer)lineBuffer).position(destinationPosition); ((Buffer)lineBuffer).flip(); return lineBuffer; } @@ -228,8 +228,8 @@ public abstract class AbstractSocket imp this.utf8Encoder.flush(this.bufferOut); written += this.writeFromBufferOut(this.bufferOut); - this.stringsEncoded.clear(); - this.bufferOut.clear(); + ((Buffer)this.stringsEncoded).clear(); + ((Buffer)this.bufferOut).clear(); if(written == 0) { throw new IOException("The query could not be sent to the server!"); } else { @@ -253,14 +253,14 @@ public abstract class AbstractSocket imp for (int i = 0; i < limit; i++) { if (destinationPosition >= destinationCapacity) { - this.stringsEncoded.position(destinationPosition); + ((Buffer)this.stringsEncoded).position(destinationPosition); this.writeToOutputBuffer(false); destinationArray = this.stringsEncoded.array(); destinationPosition = 0; } destinationArray[destinationPosition++] = line.charAt(i); } - this.stringsEncoded.position(destinationPosition); + ((Buffer)this.stringsEncoded).position(destinationPosition); } /**
--- a/src/main/java/nl/cwi/monetdb/mcl/connection/mapi/OldMapiSocket.java +++ b/src/main/java/nl/cwi/monetdb/mcl/connection/mapi/OldMapiSocket.java @@ -210,7 +210,7 @@ public class OldMapiSocket extends Abstr } public int read(ByteBuffer b, int off, int len) throws IOException { - b.clear(); + ((Buffer)b).clear(); int t; int size = 0; while (size < len) { @@ -241,7 +241,7 @@ public class OldMapiSocket extends Abstr throw new IOException("Read from " + connection.getHostname() + ":" + connection.getPort() + ": Incomplete block read from stream"); } - b.position(size); + ((Buffer)b).position(size); ((Buffer)b).flip(); return size; } @@ -350,7 +350,7 @@ public class OldMapiSocket extends Abstr break; } } - b.clear(); + ((Buffer)b).clear(); return written; }
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java +++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java @@ -98,9 +98,9 @@ public class OldMapiProtocol extends Abs throw new IOException("Connection to server lost!"); } this.currentServerResponseHeader = OldMapiServerResponseParser.parseOldMapiServerResponse(this); - this.lineBuffer.position(0); + ((Buffer)this.lineBuffer).position(0); if (this.currentServerResponseHeader == ServerResponses.ERROR) { - this.lineBuffer.position(1); + ((Buffer)this.lineBuffer).position(1); } } } @@ -130,7 +130,7 @@ public class OldMapiProtocol extends Abs ((Buffer)newbuffer).flip(); this.lineBuffer = newbuffer; } - this.lineBuffer.position(1); + ((Buffer)this.lineBuffer).position(1); } /**
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java +++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java @@ -11,6 +11,8 @@ package nl.cwi.monetdb.mcl.protocol.oldm import nl.cwi.monetdb.mcl.protocol.ProtocolException; import nl.cwi.monetdb.mcl.protocol.StarterHeaders; +import java.nio.Buffer; + /** * The OldMapiStartOfHeaderParser is responsible to retrieve the server's headers on a SOHEADER response. Depending on * the type of the header, the next tokens should be retrieved as integers or Strings. @@ -96,7 +98,7 @@ final class OldMapiStartOfHeaderParser { throw new ProtocolException("expected a digit", currentPointer - 1); } } - protocol.lineBuffer.position(currentPointer); + ((Buffer)protocol.lineBuffer).position(currentPointer); return positive ? tmp : -tmp; } @@ -127,7 +129,7 @@ final class OldMapiStartOfHeaderParser { cnt++; } - protocol.lineBuffer.position(mark); + ((Buffer)protocol.lineBuffer).position(mark); return new String(array, 0, cnt); } }
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java +++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java @@ -103,7 +103,7 @@ final class OldMapiTupleLineParser { final int fieldlen = endpos - cursor; if (fieldHasEscape) { // reuse the tupleLineBuffer by cleaning it and ensure the capacity - tupleLineBuffer.clear(); + ((Buffer)tupleLineBuffer).clear(); tupleLineBuffer = BufferReallocator.ensureCapacity(tupleLineBuffer, (i - 2) - (cursor + 1)); // parse the field value (excluding the double quotes) and convert it to a string without any escape characters for (int pos = cursor; pos < endpos; pos++) {