bxvs888 commented on issue #3233: shardingsphere proxy 4.0.0-RC3-SNAPSHOT   
JDBC execute SQL report 
org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask - 
Exception occur:  java.lang.IndexOutOfBoundsException: readerIndex(22) + 
length(2) exceeds writerIndex(23): PooledSlicedByteBuf(ridx: 22, widx: 23, cap: 
23/23, unwrapped: 
URL: 
https://github.com/apache/incubator-shardingsphere/issues/3233#issuecomment-541287968
 
 
   
   public final class PostgreSQLStringBinaryProtocolValue implements 
PostgreSQLBinaryProtocolValue {
       
       @Override
       public int getColumnLength(final Object value) {
           return value.toString().length();
       }
       
       @Override
       public Object read(final PostgreSQLPacketPayload payload) {
   //错在这里,读时没有指定长度。
           return payload.readStringNul();
       }
   
       //public final class PostgreSQLStringBinaryProtocolValue implements 
PostgreSQLBinaryProtocolValue {
       
       @Override
       public int getColumnLength(final Object value) {
           return value.toString().length();
       }
       
       @Override
       public Object read(final PostgreSQLPacketPayload payload) {
           return payload.readStringNul();
       }
   
        @Override
        public Object read(PostgreSQLPacketPayload payload, int len) throws 
SQLException {
            byte[] result = new byte[len];
            payload.getByteBuf().readBytes(result);
           return  new String(result);
       }
       @Override
       public void write(final PostgreSQLPacketPayload payload, final Object 
value) {
           if (value instanceof byte[]) {
               payload.writeBytes((byte[]) value);
           } else {
               payload.writeStringEOF(value.toString());
           }
       }
   }
      //加入新的方法。
        @Override
        public Object read(PostgreSQLPacketPayload payload, int len) throws 
SQLException {
            byte[] result = new byte[len];
            payload.getByteBuf().readBytes(result);
           return  new String(result);
       }
       @Override
       public void write(final PostgreSQLPacketPayload payload, final Object 
value) {
           if (value instanceof byte[]) {
               payload.writeBytes((byte[]) value);
           } else {
               payload.writeStringEOF(value.toString());
           }
       }
   }
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to