deanhiller/playorm — pull request #83 by MightyE (2013-05-23 14:08:26+00:00)
Title: Long Byte Length Mismatch Patch

If Cassandra and the Play ORM framework run on different JVM versions, the byte length of Long (BigInteger.toByteArray()) may not line up correctly.

For now it is strongly recommended to run Cassandra on Java 1.6, which expects only exactly 8 bytes for Longs. Meanwhile Java 1.7 may produce 6 byte Longs, causing the below exception when attempting to store Long values.

This pull request is meant to address the byte length mismatch.

play.api.Application$$anon$1: Execution exception[[RuntimeException: com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=127.0.0.1(127.0.0.1):9160, latency=95(95), attempts=1]InvalidRequestException(why:(Expected 8 or 0 byte long (6)) [retrospect][netflow][startTime] failed validation)]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:144) [play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:140) [play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
java.lang.RuntimeException: com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=127.0.0.1(127.0.0.1):9160, latency=95(95), attempts=1]InvalidRequestException(why:(Expected 8 or 0 byte long (6)) [retrospect][netflow][startTime] failed validation)
at com.alvazan.orm.layer9z.spi.db.cassandra.CassandraSession.sendChanges(CassandraSession.java:114) ~[playorm.jar:na]
at com.alvazan.orm.logging.NoSqlRawLogger.sendChanges(NoSqlRawLogger.java:51) ~[playorm.jar:na]
at com.alvazan.orm.layer5.nosql.cache.NoSqlWriteCacheImpl.flush(NoSqlWriteCacheImpl.java:137) ~[playorm.jar:na]
at com.alvazan.orm.layer5.nosql.cache.NoSqlReadCacheImpl.flush(NoSqlReadCacheImpl.java:181) ~[playorm.jar:na]
at com.alvazan.orm.layer0.base.BaseEntityManagerImpl.flush(BaseEntityManagerImpl.java:208) ~[playorm.jar:na]
at controllers.Detail.get(Detail.java:72) ~[na:na]
Caused by: com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=127.0.0.1(127.0.0.1):9160, latency=95(95), attempts=1]InvalidRequestException(why:(Expected 8 or 0 byte long (6)) [retrospect][netflow][startTime] failed validation)
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159) ~[astyanax-1.56.18.jar:na]
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:60) ~[astyanax-1.56.18.jar:na]
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:27) ~[astyanax-1.56.18.jar:na]
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$1.execute(ThriftSyncConnectionFactoryImpl.java:136) ~[astyanax-1.56.18.jar:na]
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:69) ~[astyanax-1.56.18.jar:na]
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:248) ~[astyanax-1.56.18.jar:na]
Caused by: org.apache.cassandra.thrift.InvalidRequestException: null
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:20253) ~[cassandra-thrift-1.1.1.jar:1.1.1]
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78) ~[libthrift-0.7.0.jar:0.7.0]
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:922) ~[cassandra-thrift-1.1.1.jar:1.1.1]
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:908) ~[cassandra-thrift-1.1.1.jar:1.1.1]
at com.netflix.astyanax.thrift.ThriftKeyspaceImpl$1$1.internalExecute(ThriftKeyspaceImpl.java:105) ~[astyanax-1.56.18.jar:na]
at com.netflix.astyanax.thrift.ThriftKeyspaceImpl$1$1.internalExecute(ThriftKeyspaceImpl.java:102) ~[astyanax-1.56.18.jar:na]