changeset 1096:73500970d137

MySqlPacketTypeBasedDecoder, PgSqlFlowHandler - bugfixes
author Devel 2
date Tue, 12 May 2020 09:33:36 +0200
parents d729a8ca2552
children 29ccfdd52055
files stress-tester/src/main/java/com/passus/st/client/mysql/MySqlPacketTypeBasedDecoder.java stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandler.java
diffstat 2 files changed, 14 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/mysql/MySqlPacketTypeBasedDecoder.java	Mon May 11 14:19:47 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/mysql/MySqlPacketTypeBasedDecoder.java	Tue May 12 09:33:36 2020 +0200
@@ -49,7 +49,7 @@
             return offset - startOffset;
         }
 
-        int packetNum = data[offset++];
+        int packetNum = data[offset++] & 0xFF;
         MySqlDecoder lastDecoder;
         switch (packetType) {
             case GREETINGS:
@@ -85,33 +85,28 @@
                 lastDecoder = reqDecoder;
                 break;
             case QUERY_COMMAND:
-                offset++;
-                reqDecoder.decodeQueryCommand(data, offset, length, reqTmp);
+                reqDecoder.decodeQueryCommand(data, offset + 1, length, reqTmp);
                 lastDecoder = reqDecoder;
                 break;
             case USE_DATABASE_COMMAND:
-                offset++;
-                reqDecoder.decodeUseDatabaseCommand(data, offset, length, reqTmp);
+                reqDecoder.decodeUseDatabaseCommand(data, offset + 1, length, reqTmp);
                 lastDecoder = reqDecoder;
                 break;
             case SHOW_FIELDS_COMMAND:
-                offset++;
-                reqDecoder.decodeShowFieldsCommand(data, offset, length, reqTmp);
+                reqDecoder.decodeShowFieldsCommand(data, offset + 1, length, reqTmp);
                 lastDecoder = reqDecoder;
                 break;
             case CLOSE_STATEMENT_COMMAND:
-                offset++;
-                reqDecoder.decodeStatementCloseCommand(data, offset, reqTmp);
+                reqDecoder.decodeStatementCloseCommand(data, offset + 1, reqTmp);
                 lastDecoder = reqDecoder;
                 break;
             case QUIT_COMMAND:
-                offset++;
-                reqDecoder.decodeQueryCommand(data, offset, packetLength, reqTmp);
+                reqDecoder.decodeQueryCommand(data, offset + 1, packetLength, reqTmp);
                 lastDecoder = reqDecoder;
                 break;
             case GENERIC_COMMAND:
-                byte type = data[offset++];
-                reqDecoder.decodeGenericCommand(data, offset, packetLength, type, reqTmp);
+                byte type = data[offset];
+                reqDecoder.decodeGenericCommand(data, offset + 1, packetLength, type, reqTmp);
                 lastDecoder = reqDecoder;
                 break;
             default:
--- a/stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandler.java	Mon May 11 14:19:47 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/pgsql/PgSqlFlowHandler.java	Tue May 12 09:33:36 2020 +0200
@@ -33,6 +33,12 @@
     }
 
     @Override
+    public void init(FlowContext flowContext) {
+        super.init(flowContext);
+        flowContext.setBidirectional(true);
+    }
+
+    @Override
     public int getProtocolId() {
         return NETFLOW;
     }
@@ -101,10 +107,4 @@
         this.timeGenerator = timeGenerator;
     }
 
-    @Override
-    public void init(FlowContext flowContext) {
-        flowContext.setBidirectional(true);
-    }
-
-
 }
\ No newline at end of file