Quellcode durchsuchen

fix bug: To bit byte[]

Signed-off-by: AE86 <836391306@qq.com>
AE86 vor 2 Jahren
Ursprung
Commit
c845f6d833

+ 4 - 7
dbsyncer-connector/src/main/java/org/dbsyncer/connector/schema/BitValueMapper.java

@@ -5,6 +5,7 @@ import org.dbsyncer.connector.AbstractValueMapper;
 import org.dbsyncer.connector.ConnectorException;
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 import java.util.BitSet;
 
 /**
@@ -23,20 +24,16 @@ public class BitValueMapper extends AbstractValueMapper<byte[]> {
         if (val instanceof Integer) {
             ByteBuffer buffer = ByteBuffer.allocate(4);
             buffer.putInt((Integer) val);
-            byte[] bytes = new byte[4];
-            buffer.get(bytes);
-            return bytes;
+            return buffer.array();
         }
         if (val instanceof Boolean) {
             Boolean b = (Boolean) val;
             ByteBuffer buffer = ByteBuffer.allocate(2);
             buffer.putShort((short) (b ? 1 : 0));
-            byte[] bytes = new byte[2];
-            buffer.get(bytes);
-            return bytes;
+            return buffer.array();
         }
 
         throw new ConnectorException(String.format("%s can not find type [%s], val [%s]", getClass().getSimpleName(), val.getClass(), val));
     }
-    
+
 }