diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraAuthenticationException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraAuthenticationException.java index abb671622..0205f4a74 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraAuthenticationException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraAuthenticationException.java @@ -28,8 +28,15 @@ public class CassandraAuthenticationException extends PermissionDeniedDataAccess private static final long serialVersionUID = 8556304586797273927L; - private EndPoint host; + private final EndPoint host; + /** + * Constructor for {@link CassandraAuthenticationException}. + * + * @param host the affected endpoint. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraAuthenticationException(EndPoint host, String msg, Throwable cause) { super(msg, cause); this.host = host; diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraConnectionFailureException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraConnectionFailureException.java index 37a49a1bb..820358dfe 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraConnectionFailureException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraConnectionFailureException.java @@ -32,11 +32,18 @@ public class CassandraConnectionFailureException extends DataAccessResourceFailu private static final long serialVersionUID = 6299912054261646552L; - private final Map messagesByHost = new HashMap<>(); + private final Map messagesByHost; + /** + * Constructor for {@link CassandraConnectionFailureException}. + * + * @param map the detail failures for each node. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraConnectionFailureException(Map map, String msg, Throwable cause) { super(msg, cause); - this.messagesByHost.putAll(map); + this.messagesByHost = new HashMap<>(map); } public Map getMessagesByHost() { diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraDriverTimeOutException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraDriverTimeOutException.java deleted file mode 100644 index 73b94e711..000000000 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraDriverTimeOutException.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.springframework.data.cassandra; - -import org.springframework.dao.QueryTimeoutException; - -/** - * This exception is thrown when driver have timed out during any interation with cassandra coordinator node - * - * @author Mikhail Polivakha - */ -public class CassandraDriverTimeOutException extends QueryTimeoutException { - - public CassandraDriverTimeOutException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraDriverTimeoutException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraDriverTimeoutException.java new file mode 100644 index 000000000..ead24c6d3 --- /dev/null +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraDriverTimeoutException.java @@ -0,0 +1,22 @@ +package org.springframework.data.cassandra; + +import org.springframework.dao.QueryTimeoutException; + +/** + * This exception is thrown when driver has timed out during any interaction with the Cassandra coordinator node. + * + * @author Mikhail Polivakha + * @since 4.2 + */ +public class CassandraDriverTimeoutException extends QueryTimeoutException { + + /** + * Constructor for {@link CassandraDriverTimeoutException}. + * + * @param message the detail message. + * @param cause the root cause from the underlying data access API. + */ + public CassandraDriverTimeoutException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInsufficientReplicasAvailableException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInsufficientReplicasAvailableException.java index 3bf8734ce..1b8c939f2 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInsufficientReplicasAvailableException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInsufficientReplicasAvailableException.java @@ -29,10 +29,22 @@ public class CassandraInsufficientReplicasAvailableException extends TransientDa private int numberRequired; private int numberAlive; + /** + * Constructor for {@link CassandraInsufficientReplicasAvailableException}. + * + * @param msg the detail message. + */ public CassandraInsufficientReplicasAvailableException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraInsufficientReplicasAvailableException}. + * + * @param numberRequired the required number of replicas. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraInsufficientReplicasAvailableException(int numberRequired, int numberAlive, String msg, Throwable cause) { super(msg, cause); diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInternalException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInternalException.java index 9ee6e9868..fe88ffcee 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInternalException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInternalException.java @@ -26,10 +26,21 @@ public class CassandraInternalException extends DataAccessException { private static final long serialVersionUID = 433061676465346338L; + /** + * Constructor for {@link CassandraInternalException}. + * + * @param msg the detail message. + */ public CassandraInternalException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraInternalException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraInternalException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidConfigurationInQueryException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidConfigurationInQueryException.java index 0b53197d6..1ba724ba3 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidConfigurationInQueryException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidConfigurationInQueryException.java @@ -27,10 +27,21 @@ public class CassandraInvalidConfigurationInQueryException extends InvalidDataAc private static final long serialVersionUID = 4594321191806182918L; + /** + * Constructor for {@link CassandraInvalidConfigurationInQueryException}. + * + * @param msg the detail message. + */ public CassandraInvalidConfigurationInQueryException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraInvalidConfigurationInQueryException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraInvalidConfigurationInQueryException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidQueryException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidQueryException.java index ba4437e3a..70b67f6ae 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidQueryException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraInvalidQueryException.java @@ -26,10 +26,21 @@ public class CassandraInvalidQueryException extends InvalidDataAccessApiUsageExc private static final long serialVersionUID = 4594321191806182918L; + /** + * Constructor for {@link CassandraInvalidQueryException}. + * + * @param msg the detail message. + */ public CassandraInvalidQueryException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraInvalidQueryException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraInvalidQueryException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraKeyspaceExistsException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraKeyspaceExistsException.java index b6fa396e6..25498c26f 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraKeyspaceExistsException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraKeyspaceExistsException.java @@ -24,6 +24,13 @@ public class CassandraKeyspaceExistsException extends CassandraSchemaElementExis private static final long serialVersionUID = 6032967419751410352L; + /** + * Constructor for {@link CassandraKeyspaceExistsException}. + * + * @param keyspaceName the keyspace name. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraKeyspaceExistsException(String keyspaceName, String msg, Throwable cause) { super(keyspaceName, ElementType.KEYSPACE, msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraQuerySyntaxException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraQuerySyntaxException.java index c120daff6..7b58318a7 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraQuerySyntaxException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraQuerySyntaxException.java @@ -26,10 +26,21 @@ public class CassandraQuerySyntaxException extends InvalidDataAccessApiUsageExce private static final long serialVersionUID = 4398474399882434154L; + /** + * Constructor for {@link CassandraQuerySyntaxException}. + * + * @param msg the detail message. + */ public CassandraQuerySyntaxException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraQuerySyntaxException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraQuerySyntaxException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraReadTimeoutException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraReadTimeoutException.java index 0da70a887..720f4736d 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraReadTimeoutException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraReadTimeoutException.java @@ -30,11 +30,11 @@ public class CassandraReadTimeoutException extends QueryTimeoutException { private final boolean wasDataPresent; /** - * Constructor for QueryTimeoutException. + * Constructor for {@link CassandraReadTimeoutException}. * * @param wasDataPresent whether the actual data was amongst the received replica responses. * @param msg the detail message. - * @param cause the root cause from the data access API in use. + * @param cause the root cause from the underlying data access API. */ public CassandraReadTimeoutException(boolean wasDataPresent, String msg, Throwable cause) { super(msg, cause); diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraSchemaElementExistsException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraSchemaElementExistsException.java index f20ccaec3..6371e8b0c 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraSchemaElementExistsException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraSchemaElementExistsException.java @@ -36,6 +36,14 @@ public class CassandraSchemaElementExistsException extends NonTransientDataAcces private String elementName; private ElementType elementType; + /** + * Constructor for {@link CassandraSchemaElementExistsException}. + * + * @param elementName the CQL element name. + * @param elementType the CQL element type. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ @Deprecated public CassandraSchemaElementExistsException(String elementName, ElementType elementType, String msg, Throwable cause) { @@ -44,6 +52,12 @@ public class CassandraSchemaElementExistsException extends NonTransientDataAcces this.elementType = elementType; } + /** + * Constructor for {@link CassandraSchemaElementExistsException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraSchemaElementExistsException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTableExistsException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTableExistsException.java index 86d6cd3b7..e240abf83 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTableExistsException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTableExistsException.java @@ -24,6 +24,13 @@ public class CassandraTableExistsException extends CassandraSchemaElementExistsE private static final long serialVersionUID = 6032967419751410352L; + /** + * Constructor for {@link CassandraTableExistsException}. + * + * @param tableName the table name. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraTableExistsException(String tableName, String msg, Throwable cause) { super(tableName, ElementType.TABLE, msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTraceRetrievalException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTraceRetrievalException.java index 21ba4ec56..1208decc6 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTraceRetrievalException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTraceRetrievalException.java @@ -26,10 +26,21 @@ public class CassandraTraceRetrievalException extends TransientDataAccessExcepti private static final long serialVersionUID = -3163557220324700239L; + /** + * Constructor for {@link CassandraTraceRetrievalException}. + * + * @param msg the detail message. + */ public CassandraTraceRetrievalException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraTraceRetrievalException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraTraceRetrievalException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTruncateException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTruncateException.java index 34d8a130c..5f1dd643b 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTruncateException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTruncateException.java @@ -26,10 +26,21 @@ public class CassandraTruncateException extends TransientDataAccessException { private static final long serialVersionUID = 5730642491362430311L; + /** + * Constructor for {@link CassandraTruncateException}. + * + * @param msg the detail message. + */ public CassandraTruncateException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraTruncateException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraTruncateException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTypeMismatchException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTypeMismatchException.java index 11889a213..947535913 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTypeMismatchException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraTypeMismatchException.java @@ -26,10 +26,21 @@ public class CassandraTypeMismatchException extends TypeMismatchDataAccessExcept private static final long serialVersionUID = -7420058975444905629L; + /** + * Constructor for {@link CassandraTypeMismatchException}. + * + * @param msg the detail message. + */ public CassandraTypeMismatchException(String msg) { super(msg); } + /** + * Constructor for {@link CassandraTypeMismatchException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraTypeMismatchException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUnauthorizedException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUnauthorizedException.java index 5d91c4c04..e4a2ff24a 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUnauthorizedException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUnauthorizedException.java @@ -26,6 +26,12 @@ public class CassandraUnauthorizedException extends PermissionDeniedDataAccessEx private static final long serialVersionUID = 4618185356687726647L; + /** + * Constructor for {@link CassandraUnauthorizedException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraUnauthorizedException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUncategorizedException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUncategorizedException.java index cdd622d32..6b394a8ae 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUncategorizedException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraUncategorizedException.java @@ -27,6 +27,12 @@ public class CassandraUncategorizedException extends UncategorizedDataAccessExce private static final long serialVersionUID = 1029525121238025444L; + /** + * Constructor for {@link CassandraUncategorizedException}. + * + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + */ public CassandraUncategorizedException(String msg, Throwable cause) { super(msg, cause); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraWriteTimeoutException.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraWriteTimeoutException.java index 0c9494dfd..02c7ab788 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraWriteTimeoutException.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/CassandraWriteTimeoutException.java @@ -30,6 +30,14 @@ public class CassandraWriteTimeoutException extends QueryTimeoutException { private @Nullable String writeType; + /** + * Constructor for {@link CassandraWriteTimeoutException}. + * + * @param writeType the write type. + * @param msg the detail message. + * @param cause the root cause from the underlying data access API. + * @see com.datastax.oss.driver.api.core.servererrors.WriteType + */ public CassandraWriteTimeoutException(@Nullable String writeType, String msg, Throwable cause) { super(msg, cause); this.writeType = writeType; diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslator.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslator.java index cbdef1105..13e0c80f9 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslator.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslator.java @@ -23,22 +23,9 @@ import java.util.Set; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessResourceFailureException; -import org.springframework.dao.QueryTimeoutException; import org.springframework.dao.TransientDataAccessResourceException; import org.springframework.dao.support.PersistenceExceptionTranslator; -import org.springframework.data.cassandra.CassandraAuthenticationException; -import org.springframework.data.cassandra.CassandraConnectionFailureException; -import org.springframework.data.cassandra.CassandraDriverTimeOutException; -import org.springframework.data.cassandra.CassandraInsufficientReplicasAvailableException; -import org.springframework.data.cassandra.CassandraInvalidConfigurationInQueryException; -import org.springframework.data.cassandra.CassandraInvalidQueryException; -import org.springframework.data.cassandra.CassandraQuerySyntaxException; -import org.springframework.data.cassandra.CassandraReadTimeoutException; -import org.springframework.data.cassandra.CassandraSchemaElementExistsException; -import org.springframework.data.cassandra.CassandraTruncateException; -import org.springframework.data.cassandra.CassandraUnauthorizedException; -import org.springframework.data.cassandra.CassandraUncategorizedException; -import org.springframework.data.cassandra.CassandraWriteTimeoutException; +import org.springframework.data.cassandra.*; import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; @@ -48,19 +35,7 @@ import com.datastax.oss.driver.api.core.DriverException; import com.datastax.oss.driver.api.core.DriverTimeoutException; import com.datastax.oss.driver.api.core.auth.AuthenticationException; import com.datastax.oss.driver.api.core.metadata.Node; -import com.datastax.oss.driver.api.core.servererrors.AlreadyExistsException; -import com.datastax.oss.driver.api.core.servererrors.BootstrappingException; -import com.datastax.oss.driver.api.core.servererrors.CoordinatorException; -import com.datastax.oss.driver.api.core.servererrors.InvalidConfigurationInQueryException; -import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException; -import com.datastax.oss.driver.api.core.servererrors.OverloadedException; -import com.datastax.oss.driver.api.core.servererrors.ReadTimeoutException; -import com.datastax.oss.driver.api.core.servererrors.SyntaxError; -import com.datastax.oss.driver.api.core.servererrors.TruncateException; -import com.datastax.oss.driver.api.core.servererrors.UnauthorizedException; -import com.datastax.oss.driver.api.core.servererrors.UnavailableException; -import com.datastax.oss.driver.api.core.servererrors.WriteTimeoutException; -import com.datastax.oss.driver.api.core.servererrors.WriteType; +import com.datastax.oss.driver.api.core.servererrors.*; /** * Simple {@link PersistenceExceptionTranslator} for Cassandra. @@ -110,7 +85,7 @@ public class CassandraExceptionTranslator implements CqlExceptionTranslator { } if (exception instanceof DriverTimeoutException driverTimeoutException) { - return new CassandraDriverTimeOutException(driverTimeoutException.getMessage(), driverTimeoutException); + return new CassandraDriverTimeoutException(driverTimeoutException.getMessage(), driverTimeoutException); } if (exception instanceof ReadTimeoutException) { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslatorUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslatorUnitTests.java index adfc15e1c..c0df0c494 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslatorUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/CassandraExceptionTranslatorUnitTests.java @@ -26,19 +26,7 @@ import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.dao.TransientDataAccessResourceException; -import org.springframework.data.cassandra.CassandraAuthenticationException; -import org.springframework.data.cassandra.CassandraConnectionFailureException; -import org.springframework.data.cassandra.CassandraDriverTimeOutException; -import org.springframework.data.cassandra.CassandraInsufficientReplicasAvailableException; -import org.springframework.data.cassandra.CassandraInvalidConfigurationInQueryException; -import org.springframework.data.cassandra.CassandraInvalidQueryException; -import org.springframework.data.cassandra.CassandraQuerySyntaxException; -import org.springframework.data.cassandra.CassandraReadTimeoutException; -import org.springframework.data.cassandra.CassandraSchemaElementExistsException; -import org.springframework.data.cassandra.CassandraTruncateException; -import org.springframework.data.cassandra.CassandraUnauthorizedException; -import org.springframework.data.cassandra.CassandraUncategorizedException; -import org.springframework.data.cassandra.CassandraWriteTimeoutException; +import org.springframework.data.cassandra.*; import com.datastax.oss.driver.api.core.DefaultConsistencyLevel; import com.datastax.oss.driver.api.core.DriverTimeoutException; @@ -50,20 +38,7 @@ import com.datastax.oss.driver.api.core.connection.BusyConnectionException; import com.datastax.oss.driver.api.core.connection.FrameTooLongException; import com.datastax.oss.driver.api.core.metadata.EndPoint; import com.datastax.oss.driver.api.core.metadata.Node; -import com.datastax.oss.driver.api.core.servererrors.AlreadyExistsException; -import com.datastax.oss.driver.api.core.servererrors.BootstrappingException; -import com.datastax.oss.driver.api.core.servererrors.InvalidConfigurationInQueryException; -import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException; -import com.datastax.oss.driver.api.core.servererrors.OverloadedException; -import com.datastax.oss.driver.api.core.servererrors.ReadFailureException; -import com.datastax.oss.driver.api.core.servererrors.ReadTimeoutException; -import com.datastax.oss.driver.api.core.servererrors.SyntaxError; -import com.datastax.oss.driver.api.core.servererrors.TruncateException; -import com.datastax.oss.driver.api.core.servererrors.UnauthorizedException; -import com.datastax.oss.driver.api.core.servererrors.UnavailableException; -import com.datastax.oss.driver.api.core.servererrors.WriteFailureException; -import com.datastax.oss.driver.api.core.servererrors.WriteTimeoutException; -import com.datastax.oss.driver.api.core.servererrors.WriteType; +import com.datastax.oss.driver.api.core.servererrors.*; import com.datastax.oss.driver.api.core.type.DataTypes; import com.datastax.oss.driver.api.core.type.codec.CodecNotFoundException; import com.datastax.oss.driver.api.core.type.reflect.GenericType; @@ -120,11 +95,13 @@ class CassandraExceptionTranslatorUnitTests { .hasMessageStartingWith("message").hasCauseInstanceOf(InvalidConfigurationInQueryException.class); } - @Test - void shouldRecognizeDriverTimeoutException() { + @Test // GH-1399 + void shouldTranslateDriverTimeoutException() { + DataAccessException dataAccessException = sut.translateExceptionIfPossible(new DriverTimeoutException("message")); - assertThat(dataAccessException).isInstanceOf(CassandraDriverTimeOutException.class).hasMessageStartingWith("message") + assertThat(dataAccessException).isInstanceOf(CassandraDriverTimeoutException.class) + .hasMessageStartingWith("message") .hasCauseInstanceOf(DriverTimeoutException.class); }