You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "ThorneANN (via GitHub)" <gi...@apache.org> on 2026/03/02 02:49:40 UTC

[I] [Bug][Lake][Paimon] NullPointerException in FlussRecordAsPaimonRow when setFlussRecord() is not called before accessing row data [fluss]

ThorneANN opened a new issue, #2762:
URL: https://github.com/apache/fluss/issues/2762

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.
   
   
   ### Fluss version
   
   main (development)
   
   ### Please describe the bug 🐞
   
                                                                                                                                                                                     
     `FlussRecordAsPaimonRow` uses a reuse pattern where `setFlussRecord()` must be                                                                                                     
     called before any row accessor methods are invoked. However, the class provides                                                                                                  
     no guard against being accessed in an uninitialized state, causing an opaque                                                                                                       
     `NullPointerException` rather than a clear, actionable error message.                                                                                                              
   
     ## Affected Methods
   
     The following methods access `logRecord` directly without checking whether it
     has been initialized:
   
   ```
   `getRowKind()` — calls `logRecord.getChangeType()`
   `getLong(int pos)` — calls `logRecord.logOffset()` / `logRecord.timestamp()`
   `getTimestamp(int pos, int precision)` — calls `logRecord.timestamp()`
   ```
   
     ## Root Cause
   
     `FlussRecordAsPaimonRow` is constructed once and reused per bucket in
     `RecordWriter`. The field `logRecord` is `null` by default (Java semantics).
     If a caller accesses any of the above methods before calling `setFlussRecord()`,
     or passes `null` to `setFlussRecord()`, a `NullPointerException` is thrown with
     no context about the actual cause.
   
   ```
     ```java
     // logRecord is null until setFlussRecord() is called
     public RowKind getRowKind() {
         return toRowKind(logRecord.getChangeType()); // NPE here
     }
   ```
   
   ### Solution
   
   Two defensive checks are added:
   
     1. In setFlussRecord() — reject null input immediately at the entry point.
     2. In each affected getter — assert that logRecord has been initialized
     before accessing it, providing a clear error message pointing to the
     incorrect usage order.
   
   ```
     public void setFlussRecord(LogRecord logRecord) {
         checkState(logRecord != null, "logRecord must not be null.");
         ...
     }
   ```
   
   ```
     @Override
     public RowKind getRowKind() {
         checkState(logRecord != null, "setFlussRecord() must be called before accessing the row.");
         return toRowKind(logRecord.getChangeType());
     }
   ```
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
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: issues-unsubscribe@fluss.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Lake][Paimon] NullPointerException in FlussRecordAsPaimonRow when setFlussRecord() is not called before accessing row data [fluss]

Posted by "ThorneANN (via GitHub)" <gi...@apache.org>.
ThorneANN closed issue #2762: [Bug][Lake][Paimon] NullPointerException in FlussRecordAsPaimonRow when setFlussRecord() is not called before accessing row data
URL: https://github.com/apache/fluss/issues/2762


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org