Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix NPE in DoubleSerializer for nonexistent columns #421

Merged
merged 1 commit into from

2 participants

@amrik

DoubleSerializer uses LongSerializer internally. However whenever LongSerializer returns null (such as when the column does not exist) this would cause a NullPointerException.

Here I add some guards similar to what already exist in LongSerializer.

@zznate
Collaborator

Good catch - thanks.

@zznate zznate merged commit 59de8d1 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2012
  1. @amrik
This page is out of date. Refresh to see the latest.
View
6 core/src/main/java/me/prettyprint/cassandra/serializers/DoubleSerializer.java
@@ -20,12 +20,16 @@ public static DoubleSerializer get() {
@Override
public ByteBuffer toByteBuffer(Double obj) {
+ if (obj == null) {
+ return null;
+ }
return LongSerializer.get().toByteBuffer(Double.doubleToRawLongBits(obj));
}
@Override
public Double fromByteBuffer(ByteBuffer bytes) {
- return Double.longBitsToDouble (LongSerializer.get().fromByteBuffer(bytes));
+ Long l = LongSerializer.get().fromByteBuffer(bytes);
+ return l == null ? null : Double.longBitsToDouble (l);
}
}
Something went wrong with that request. Please try again.