Closed wsky closed 11 years ago
public static void writeMessage(ByteBuffer buffer, Message message) { buffer.order(ByteOrder.LITTLE_ENDIAN); //... buffer.order(ByteOrder.BIG_ENDIAN); buffer.flip(); }
but in writeCustomValue, order was changed...
private static void writeCustomValue(ByteBuffer buffer, Object value) { if (value == null) { buffer.put(ValueFormat.Void); return; } Class<?> type = value.getClass(); if (byte.class.equals(type) || Byte.class.equals(type)) { buffer.put(ValueFormat.Byte); buffer.put((Byte) value); } else if (short.class.equals(type) || Short.class.equals(type)) { buffer.put(ValueFormat.Int16); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putShort((Short) value); buffer.order(ByteOrder.BIG_ENDIAN); } else if (int.class.equals(type) || Integer.class.equals(type)) { buffer.put(ValueFormat.Int32); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt((Integer) value); buffer.order(ByteOrder.BIG_ENDIAN); } else if (long.class.equals(type) || Long.class.equals(type)) { buffer.put(ValueFormat.Int64); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putLong((Long) value); buffer.order(ByteOrder.BIG_ENDIAN); } else if (Date.class.equals(type)) { buffer.put(ValueFormat.Date); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putLong(((Date) value).getTime()); buffer.order(ByteOrder.BIG_ENDIAN); } else { buffer.put(ValueFormat.CountedString); writeCountedString(buffer, (String) value); } }
must fix at next releas
must support version for compatible
but in writeCustomValue, order was changed...