HHH-13722 ArrayStoreException in Constraint.generateName

This commit is contained in:
Sanne Grinovero 2019-11-18 14:51:36 +00:00
parent 76308e8a3e
commit 7331a58d5e
1 changed files with 10 additions and 1 deletions

View File

@ -75,7 +75,16 @@ public abstract class Constraint implements RelationalModel, Exportable, Seriali
* @return String The generated name
*/
public static String generateName(String prefix, Table table, List<Column> columns) {
return generateName( prefix, table, columns.toArray( new Column[columns.size()] ) );
//N.B. legacy APIs are involved: can't trust that the columns List is actually
//containing Column instances - the generic type isn't consistently enforced.
ArrayList<Column> defensive = new ArrayList<>( columns.size() );
for ( Object o : columns ) {
if ( o instanceof Column ) {
defensive.add( (Column) o );
}
//else: others might be Formula instances. They don't need to be part of the name generation.
}
return generateName( prefix, table, defensive.toArray( new Column[0] ) );
}
/**