thswlsqls opened a new issue, #17044:
URL: https://github.com/apache/iceberg/issues/17044

   **Apache Iceberg version**
   main @ 035fc1e40
   
   **Query engine**
   N/A — engine-agnostic, in `common/`
   
   **Please describe the bug**
   `DynFields.Builder.build(target)` / `.buildChecked(target)` throws a 
`NullPointerException` instead of returning a field bound to `null`, when 
`defaultAlwaysNull()` is set and no matching field is found.
   
   `DynFields.AlwaysNull` 
(`common/src/main/java/org/apache/iceberg/common/DynFields.java` line 120-149) 
is a singleton constructed with a `null` `Field` (`super(null, "AlwaysNull")`, 
line 124). It does not override `bind(Object)`, so calls fall through to the 
parent `UnboundField.bind()` (line 86-96), which dereferences the null field 
via `field.getDeclaringClass()` (line 90).
   
   The sibling class `DynMethods.UnboundMethod.NOOP` (`DynMethods.java` line 
134-137) already avoids this exact problem by overriding `bind()` to return 
`new BoundMethod(this, receiver)` directly, without touching the null `method` 
field.
   
   **Steps to reproduce**
   ```java
   DynFields.builder().defaultAlwaysNull().build(new Object());
   ```
   Expected: returns a `BoundField` whose `get()` returns `null` (per 
`defaultAlwaysNull()`'s contract).
   Actual: `NullPointerException: Cannot invoke 
"java.lang.reflect.Field.getDeclaringClass()" because "this.field" is null` at 
`DynFields.java:90`.
   
   **Additional context**
   Reproduced by running against the compiled `common` module (same failure via 
`buildChecked(target)`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to