mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-4.1' into cassandra-5.0
This commit is contained in:
commit
b23db408c5
|
|
@ -7,6 +7,7 @@
|
||||||
Merged from 4.1:
|
Merged from 4.1:
|
||||||
* Redact security-sensitive information in system_views.settings (CASSANDRA-20856)
|
* Redact security-sensitive information in system_views.settings (CASSANDRA-20856)
|
||||||
Merged from 4.0:
|
Merged from 4.0:
|
||||||
|
* Fixed incorrect error message constant for keyspace name length validation (CASSANDRA-20915)
|
||||||
* Prevent too long table names not fitting file names (CASSANDRA-20389)
|
* Prevent too long table names not fitting file names (CASSANDRA-20389)
|
||||||
* Update Jackson to 2.19.2 (CASSANDRA-20848)
|
* Update Jackson to 2.19.2 (CASSANDRA-20848)
|
||||||
* Update commons-lang3 to 3.18.0 (CASSANDRA-20849)
|
* Update commons-lang3 to 3.18.0 (CASSANDRA-20849)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ import org.apache.cassandra.service.StorageService;
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.any;
|
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).
|
* An immutable representation of keyspace metadata (name, params, tables, types, and functions).
|
||||||
|
|
@ -68,7 +67,7 @@ public final class KeyspaceMetadata implements SchemaElement
|
||||||
keyspaceName));
|
keyspaceName));
|
||||||
if (keyspaceName.length() > SchemaConstants.NAME_LENGTH)
|
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\")",
|
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
|
public enum Kind
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue