Merge branch 'cassandra-4.0' into cassandra-4.1

This commit is contained in:
Stefan Miklosovic 2025-09-24 10:19:03 +02:00
commit 4a201d4f6f
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
3 changed files with 47 additions and 2 deletions

View File

@ -1,6 +1,7 @@
4.1.11
* Redact security-sensitive information in system_views.settings (CASSANDRA-20856)
Merged from 4.0:
* Fixed incorrect error message constant for keyspace name length validation (CASSANDRA-20915)
* update shaded cassandra-driver-core to 3.11.5 (CASSANDRA-20904)

View File

@ -45,7 +45,6 @@ import org.apache.cassandra.service.StorageService;
import static java.lang.String.format;
import static com.google.common.collect.Iterables.any;
import static org.apache.cassandra.schema.SchemaConstants.TABLE_NAME_LENGTH;
/**
* An immutable representation of keyspace metadata (name, params, tables, types, and functions).
@ -66,7 +65,7 @@ public final class KeyspaceMetadata implements SchemaElement
keyspaceName));
if (keyspaceName.length() > SchemaConstants.NAME_LENGTH)
throw exceptionBuilder.apply(format("Keyspace name must not be more than %d characters long (got %d characters for \"%s\")",
TABLE_NAME_LENGTH, keyspaceName.length(), keyspaceName));
SchemaConstants.NAME_LENGTH, keyspaceName.length(), keyspaceName));
}
public enum Kind

View File

@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cassandra.schema;
import org.junit.Test;
import org.apache.cassandra.exceptions.ConfigurationException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class KeyspaceMetadataTest
{
@Test
public void testValidateKeyspaceNameTooLongShowsCorrectLimit()
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < SchemaConstants.NAME_LENGTH + 1; i++)
sb.append('a');
String longKeyspaceName = sb.toString();
String expectedMessage = String.format("Keyspace name must not be more than %d characters long (got %d characters for \"%s\")",
SchemaConstants.NAME_LENGTH,
longKeyspaceName.length(),
longKeyspaceName);
assertThatThrownBy(() -> KeyspaceMetadata.validateKeyspaceName(longKeyspaceName, ConfigurationException::new))
.isInstanceOf(ConfigurationException.class)
.hasMessage(expectedMessage);
}
}