HHH-17807 fix NPE in array argument validation
probably only occurs when the argument is a parameter
This commit is contained in:
parent
691a2d8109
commit
5a7661be5c
|
@ -50,21 +50,27 @@ public class ArrayArgumentValidator implements ArgumentsValidator {
|
||||||
String functionName,
|
String functionName,
|
||||||
TypeConfiguration typeConfiguration) {
|
TypeConfiguration typeConfiguration) {
|
||||||
final SqmTypedNode<?> arrayArgument = arguments.get( arrayIndex );
|
final SqmTypedNode<?> arrayArgument = arguments.get( arrayIndex );
|
||||||
final SqmExpressible<?> arrayType = arrayArgument.getExpressible().getSqmType();
|
final SqmExpressible<?> expressible = arrayArgument.getExpressible();
|
||||||
if ( arrayType == null ) {
|
if ( expressible == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if ( !( arrayType instanceof BasicPluralType<?, ?> ) ) {
|
else {
|
||||||
throw new FunctionArgumentException(
|
final SqmExpressible<?> arrayType = expressible.getSqmType();
|
||||||
String.format(
|
if ( arrayType == null ) {
|
||||||
"Parameter %d of function '%s()' requires an array type, but argument is of type '%s'",
|
return null;
|
||||||
arrayIndex,
|
}
|
||||||
functionName,
|
else if ( !( arrayType instanceof BasicPluralType<?, ?> ) ) {
|
||||||
arrayType.getTypeName()
|
throw new FunctionArgumentException(
|
||||||
)
|
String.format(
|
||||||
);
|
"Parameter %d of function '%s()' requires an array type, but argument is of type '%s'",
|
||||||
|
arrayIndex,
|
||||||
|
functionName,
|
||||||
|
arrayType.getTypeName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (BasicPluralType<?, ?>) arrayType;
|
||||||
}
|
}
|
||||||
return (BasicPluralType<?, ?>) arrayType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BasicType<?> getElementType(
|
protected BasicType<?> getElementType(
|
||||||
|
|
|
@ -31,10 +31,13 @@ public class ArrayContainsArgumentValidator extends ArrayArgumentValidator {
|
||||||
List<? extends SqmTypedNode<?>> arguments,
|
List<? extends SqmTypedNode<?>> arguments,
|
||||||
String functionName,
|
String functionName,
|
||||||
TypeConfiguration typeConfiguration) {
|
TypeConfiguration typeConfiguration) {
|
||||||
final BasicPluralType<?, ?> haystackType = getPluralType( 0, arguments, functionName, typeConfiguration );
|
final BasicPluralType<?, ?> haystackType =
|
||||||
|
getPluralType( 0, arguments, functionName, typeConfiguration );
|
||||||
final SqmExpressible<?> expressible = arguments.get( 1 ).getExpressible();
|
final SqmExpressible<?> expressible = arguments.get( 1 ).getExpressible();
|
||||||
final SqmExpressible<?> needleType = expressible == null ? null : expressible.getSqmType();
|
final SqmExpressible<?> needleType = expressible == null ? null : expressible.getSqmType();
|
||||||
if ( needleType != null && !haystackType.equals( needleType ) && !haystackType.getElementType().equals( needleType ) ) {
|
if ( haystackType!= null && needleType != null
|
||||||
|
&& !haystackType.equals( needleType )
|
||||||
|
&& !haystackType.getElementType().equals( needleType ) ) {
|
||||||
throw new FunctionArgumentException(
|
throw new FunctionArgumentException(
|
||||||
String.format(
|
String.format(
|
||||||
"Parameter 1 of function '%s()' has type %s, but argument is of type '%s'",
|
"Parameter 1 of function '%s()' has type %s, but argument is of type '%s'",
|
||||||
|
|
Loading…
Reference in New Issue