spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
381 stars 311 forks source link

CassandraAdminTemplate.getKeyspaceMetadata() fail for a case-sensitive keyspace [DATACASS-720] #887

Closed spring-projects-issues closed 4 years ago

spring-projects-issues commented 4 years ago

Samuel Padou opened DATACASS-720 and commented

Using CassandraAdminTemplate.getKeyspaceMetadata() when connected to a case-sensitive keyspace (using quotes) fail to retrieve the metadata.

Look like in this line:

KeyspaceMetadata keyspaceMetadata = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());

session.getLoggedKeyspace() does not automatically quote the keyspace identifier if needed, but metadata.getKeyspace() expect it to be (otherwise it use the lowercase keyspace and does not find it). Using Metadata.quoteIfNecessary() around the logged keyspace should work i think


Affects: 2.1.15 (Lovelace SR15), 2.2.4 (Moore SR4)

Referenced from: pull request https://github.com/spring-projects/spring-data-cassandra/pull/170, and commits https://github.com/spring-projects/spring-data-cassandra/commit/39cce44addce7342406f3e6c238d8515874f74d4, https://github.com/spring-projects/spring-data-cassandra/commit/89ac6cfb084c0680a1bfa96f9b0215aa3a350146, https://github.com/spring-projects/spring-data-cassandra/commit/80e61894842b3c9c1beebe3d306253c1cd5544fc, https://github.com/spring-projects/spring-data-cassandra/commit/3ed752ff3981914bfa0b5f3603652afbc0e741a0, https://github.com/spring-projects/spring-data-cassandra/commit/bd0b3bd7a3e923fdd98e822faa3185bb9de25c6f, https://github.com/spring-projects/spring-data-cassandra/commit/3a145b1df059ddcfc90054e966921b46328e261f

Backported to: 2.1.16 (Lovelace SR16)

spring-projects-issues commented 4 years ago

Mark Paluch commented

Good catch. Care to submit a pull request against the 2.2.x branch? Our current master has upgraded already to the Cassandra driver 4 which uses internally CqlIdentifier and does no longer face this issue

spring-projects-issues commented 4 years ago

Samuel Padou commented

Sure, added a pull request for this fix: https://github.com/spring-projects/spring-data-cassandra/pull/170