Repository navigation
Conversation
…when called through FunctionExpression.getFunction()
Calling apply() on the function that FunctionExpression.getFunction()
returns for a lambda with no parameters threw:
java.lang.NullPointerException: Cannot read the array length because "args" is null
at org.apache.calcite.linq4j.tree.FunctionExpression.lambda$compile$0(FunctionExpression.java:88)
That function is a java.lang.reflect.Proxy. For an interface method that
takes no arguments, such as Function0.apply(), the JDK calls the proxy's
InvocationHandler with a null argument array, and the invokable built by
compile() reads its length. The handler now passes an empty array when
it receives null.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
rubenada
reviewed
Oct 14, 2026
rubenada
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Calling
apply()on the function thatFunctionExpression.getFunction()returns for a lambda with no parameters throwsjava.lang.NullPointerException: Cannot read the array length because "args" is nullfromFunctionExpression.lambda$compile$0. That function is ajava.lang.reflect.Proxy, and for an interface method with no arguments, such asFunction0.apply(), the JDK calls the proxy'sInvocationHandlerwith a null argument array (InvocationHandler.invoke). The handler now passes an empty array toInvokable.dynamicInvokewhen it receives null.ExpressionTest.testLambdaWithoutParametersViaGetFunction(new) fails with that NullPointerException without the fix and passes with it.The fix and the test come from CALCITE-7736 (#5213), which carries the same change inside the nullness migration; this PR lets it land on its own.
🤖 Generated with Claude Code