Skip to content

Commit c102b83

Browse files
committed
HHH-16609 SQLFunctionRegistry#findSQLFunction needs to guard against null argument
1 parent b38cf9b commit c102b83

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ public SQLFunctionRegistry(Dialect dialect, Map<String, SQLFunction> userFunctio
3939
*
4040
* @param functionName The name of the function to locate
4141
*
42-
* @return The located function, maye return {@code null}
42+
* @return The located function, may return {@code null}
4343
*/
44-
public SQLFunction findSQLFunction(String functionName) {
44+
public SQLFunction findSQLFunction(final String functionName) {
45+
if ( functionName == null ) {
46+
return null;
47+
}
4548
return functionMap.get( functionName );
4649
}
4750

hibernate-core/src/test/java/org/hibernate/sql/TemplateTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ public static void closeSessionFactory() {
107107
}
108108
}
109109

110+
@Test
111+
public void testNullToFunction() {
112+
//Apparently this may happen during HQL parsing given a wrong syntax
113+
FUNCTION_REGISTRY.findSQLFunction( null );
114+
}
115+
110116
@Test
111117
public void testSqlExtractFunction() {
112118
String fragment = "extract( year from col )";

0 commit comments

Comments
 (0)