From b3289af1e2b96d91fe2c4c79a9dbe863628e3c11 Mon Sep 17 00:00:00 2001 From: Stefan Birkner Date: Sat, 9 Apr 2016 00:00:00 +0000 Subject: [PATCH] DATACASS-275 - Don't use deprecated methods. The method DataType.deserialize(ByteBuffer) is deprecated and throws an `UnsupportedOperationException`. This methods will be removed in future versions of the driver. By not using them anymore we make it easier to upgrade the driver afterwards. Original pull request: #49. Related ticket: DATACASS-198 CLA: 172420160413064110 (Stefan Birkner) --- .../config/PoolingOptionsFactoryBean.java | 15 ++++++--------- .../core/converter/RowToListConverter.java | 4 +++- .../convert/RowReaderPropertyAccessor.java | 3 ++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spring-cql/src/main/java/org/springframework/cassandra/config/PoolingOptionsFactoryBean.java b/spring-cql/src/main/java/org/springframework/cassandra/config/PoolingOptionsFactoryBean.java index 97a87436e..a2dde2f44 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/config/PoolingOptionsFactoryBean.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/config/PoolingOptionsFactoryBean.java @@ -71,16 +71,15 @@ public class PoolingOptionsFactoryBean implements FactoryBean, I * If the new min is greater than the current Max, set the current max to the new min first. * This is enforced by the DSE Driver so you cannot set a new min/max together if either one falls outside of the default 25-100 range. */ - int currentMax = poolingOptions.getMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL); + int currentMax = poolingOptions.getNewConnectionThreshold(HostDistance.LOCAL); if (currentMax < localMinSimultaneousRequests) { - poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, + poolingOptions.setNewConnectionThreshold(HostDistance.LOCAL, localMinSimultaneousRequests); } - poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, localMinSimultaneousRequests); } if (localMaxSimultaneousRequests != null) { - poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, localMaxSimultaneousRequests); + poolingOptions.setNewConnectionThreshold(HostDistance.LOCAL, localMaxSimultaneousRequests); } if (remoteMaxConnections != null) { @@ -96,17 +95,15 @@ public class PoolingOptionsFactoryBean implements FactoryBean, I * If the new min is greater than the current Max, set the current max to the new min first. * This is enforced by the DSE Driver so you cannot set a new min/max together if either one falls outside of the default 25-100 range. */ - int currentMax = poolingOptions.getMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE); + int currentMax = poolingOptions.getNewConnectionThreshold(HostDistance.REMOTE); if (currentMax < remoteMinSimultaneousRequests) { - poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, + poolingOptions.setNewConnectionThreshold(HostDistance.REMOTE, remoteMinSimultaneousRequests); } - poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, - remoteMinSimultaneousRequests); } if (remoteMaxSimultaneousRequests != null) { - poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, + poolingOptions.setNewConnectionThreshold(HostDistance.REMOTE, remoteMaxSimultaneousRequests); } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/RowToListConverter.java b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/RowToListConverter.java index 78911033e..2a06d0a5b 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/RowToListConverter.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/RowToListConverter.java @@ -6,6 +6,7 @@ import java.util.List; import org.springframework.core.convert.converter.Converter; import com.datastax.driver.core.ColumnDefinitions; +import com.datastax.driver.core.ProtocolVersion; import com.datastax.driver.core.Row; import com.datastax.driver.core.ColumnDefinitions.Definition; @@ -23,7 +24,8 @@ public class RowToListConverter implements Converter> { for (Definition def : cols.asList()) { String name = def.getName(); - list.add(row.isNull(name) ? null : def.getType().deserialize(row.getBytesUnsafe(name))); + list.add(row.isNull(name) ? null : def.getType().deserialize( + row.getBytesUnsafe(name), ProtocolVersion.NEWEST_SUPPORTED)); } return list; diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/RowReaderPropertyAccessor.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/RowReaderPropertyAccessor.java index 82398bc75..48b7c8ef8 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/RowReaderPropertyAccessor.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/RowReaderPropertyAccessor.java @@ -22,6 +22,7 @@ import org.springframework.expression.PropertyAccessor; import org.springframework.expression.TypedValue; import com.datastax.driver.core.DataType; +import com.datastax.driver.core.ProtocolVersion; import com.datastax.driver.core.Row; /** @@ -51,7 +52,7 @@ enum RowReaderPropertyAccessor implements PropertyAccessor { } DataType columnType = row.getColumnDefinitions().getType(name); ByteBuffer bytes = row.getBytes(name); - Object object = columnType.deserialize(bytes); + Object object = columnType.deserialize(bytes, ProtocolVersion.NEWEST_SUPPORTED); return new TypedValue(object); }