mirror of https://github.com/apache/cassandra
Fixed incorrect error message constant for keyspace name length validation
patch by Yifan Cai; reviewed by Maxwell Guo, Stefan Miklosovic for CASSANDRA-20915
This commit is contained in:
parent
d966547d01
commit
90f231ad56
|
|
@ -1,4 +1,5 @@
|
|||
4.0.19
|
||||
* Fixed incorrect error message constant for keyspace name length validation (CASSANDRA-20915)
|
||||
* update shaded cassandra-driver-core to 3.11.5 (CASSANDRA-20904)
|
||||
* Prevent too long table names not fitting file names (CASSANDRA-20389)
|
||||
* Fix IndexOutOfBoundsException in sstablemetadata tool when a range tombstone is a max clustering value (CASSANDRA-20855)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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