mirror of https://github.com/apache/cassandra
Fix potential NumberFormatException when deserializing IntegerType
patch by slebresne; reviewed by jbellis for CASSANDRA-7088
This commit is contained in:
parent
0490abff4e
commit
d6f32e4fc0
|
|
@ -4,6 +4,7 @@
|
|||
* return all cpu values from BackgroundActivityMonitor.readAndCompute (CASSANDRA-7183)
|
||||
* fix c* launch issues on Russian os's due to output of linux 'free' cmd (CASSANDRA-6162)
|
||||
* Fix disabling autocompaction (CASSANDRA-7187)
|
||||
* Fix potential NumberFormatException when deserializing IntegerType (CASSANDRA-7088)
|
||||
|
||||
2.0.8
|
||||
* Correctly delete scheduled range xfers (CASSANDRA-7143)
|
||||
|
|
|
|||
|
|
@ -153,8 +153,7 @@ public abstract class AbstractType<T> implements Comparator<ByteBuffer>
|
|||
TypeSerializer<T> serializer = getSerializer();
|
||||
serializer.validate(bytes);
|
||||
|
||||
T value = serializer.deserialize(bytes);
|
||||
return value == null ? "null" : serializer.toString(value);
|
||||
return serializer.toString(serializer.deserialize(bytes));
|
||||
}
|
||||
|
||||
/** get a byte representation of the given string. */
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class InetAddressSerializer implements TypeSerializer<InetAddress>
|
|||
|
||||
public String toString(InetAddress value)
|
||||
{
|
||||
return value.getHostAddress();
|
||||
return value == null ? "" : value.getHostAddress();
|
||||
}
|
||||
|
||||
public Class<InetAddress> getType()
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ public class IntegerSerializer implements TypeSerializer<BigInteger>
|
|||
|
||||
public BigInteger deserialize(ByteBuffer bytes)
|
||||
{
|
||||
return new BigInteger(ByteBufferUtil.getArray(bytes));
|
||||
return bytes.hasRemaining() ? new BigInteger(ByteBufferUtil.getArray(bytes)) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer serialize(BigInteger value)
|
||||
{
|
||||
return ByteBuffer.wrap(value.toByteArray());
|
||||
return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBuffer.wrap(value.toByteArray());
|
||||
}
|
||||
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
|
|
@ -44,7 +44,7 @@ public class IntegerSerializer implements TypeSerializer<BigInteger>
|
|||
|
||||
public String toString(BigInteger value)
|
||||
{
|
||||
return value.toString(10);
|
||||
return value == null ? "" : value.toString(10);
|
||||
}
|
||||
|
||||
public Class<BigInteger> getType()
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class LongSerializer implements TypeSerializer<Long>
|
|||
|
||||
public String toString(Long value)
|
||||
{
|
||||
return String.valueOf(value);
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
|
||||
public Class<Long> getType()
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class TimestampSerializer implements TypeSerializer<Date>
|
|||
|
||||
public String toString(Date value)
|
||||
{
|
||||
return FORMATTER.get().format(value);
|
||||
return value == null ? "" : FORMATTER.get().format(value);
|
||||
}
|
||||
|
||||
public Class<Date> getType()
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class UUIDSerializer implements TypeSerializer<UUID>
|
|||
|
||||
public String toString(UUID value)
|
||||
{
|
||||
return value.toString();
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
public Class<UUID> getType()
|
||||
|
|
|
|||
Loading…
Reference in New Issue