10000 add not-null assertions to catch something that should not be allowed… · hibernate/hibernate-orm@fd7f897 · GitHub
[go: up one dir, main page]

Skip to content

Commit fd7f897

Browse files
committed
add not-null assertions to catch something that should not be allowed to happen
1 parent 2f0a34b commit fd7f897

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/naming/NamingHelper.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public String generateHashedFkName(
6868
Identifier... columnNames) {
6969
// Use a concatenation that guarantees uniqueness, even if identical
7070
// names exist between all table and column identifiers.
71-
final StringBuilder sb = new StringBuilder()
71+
final StringBuilder text = new StringBuilder()
7272
.append( "table`" ).append( tableName ).append( "`" )
7373
.append( "references`" ).append( referencedTableName ).append( "`" );
7474
// Ensure a consistent ordering of columns, regardless of the order
@@ -78,9 +78,10 @@ public String generateHashedFkName(
7878
final Identifier[] alphabeticalColumns = columnNames.clone();
7979
Arrays.sort( alphabeticalColumns, comparing( Identifier::getCanonicalName ) );
8080
for ( Identifier columnName : alphabeticalColumns ) {
81-
sb.append( "column`" ).append( columnName ).append( "`" );
81+
assert columnName != null;
82+
text.append( "column`" ).append( columnName ).append( "`" );
8283
}
83-
return prefix + hashedName( sb.toString() );
84+
return prefix + hashedName( text.toString() );
8485
}
8586

8687
/**
@@ -93,17 +94,18 @@ public String generateHashedConstraintName(
9394
String prefix, Identifier tableName, Identifier... columnNames ) {
9495
// Use a concatenation that guarantees uniqueness, even if identical
9596
// names exist between all table and column identifiers.
96-
final StringBuilder sb = new StringBuilder( "table`" + tableName + "`" );
97+
final StringBuilder text = new StringBuilder( "table`" + tableName + "`" );
9798
// Ensure a consistent ordering of columns, regardless of the order
9899
// they were bound.
99100
// Clone the list, as sometimes a set of order-dependent Column
100101
// bindings are given.
101102
final Identifier[] alphabeticalColumns = columnNames.clone();
102103
Arrays.sort( alphabeticalColumns, comparing(Identifier::getCanonicalName) );
103104
for ( Identifier columnName : alphabeticalColumns ) {
104-
sb.append( "column`" ).append( columnName ).append( "`" );
105+
assert columnName != null;
106+
text.append( "column`" ).append( columnName ).append( "`" );
105107
}
106-
return prefix + hashedName( sb.toString() );
108+
return prefix + hashedName( text.toString() );
107109
}
108110

109111
/**

0 commit comments

Comments
 (0)
0