dkranchii opened a new pull request, #19261:
URL: https://github.com/apache/pinot/pull/19261
## Summary
`RealtimeSegmentDataManager.buildSegmentInternal` used a Java `assert`
before indexing into `tempSegmentFolder.listFiles()`:
```java
File[] tempFiles = tempSegmentFolder.listFiles();
assert tempFiles != null;
File tempIndexDir = tempFiles[0];
```
Java `assert` is a no-op unless the JVM is started with `-ea`, and Pinot's
service processes do not run with assertions enabled. If `listFiles()` returned
`null` (I/O error, folder gone) or an empty array (race with cleanup),
production would raise `NullPointerException` /
`ArrayIndexOutOfBoundsException` instead of the typed
`SegmentBuildFailureException` that the caller and the Helix state machine
already handle. That leaves the realtime segment commit in an ambiguous state.
## Change
- Extract a small `@VisibleForTesting` static helper
`pickTempIndexDir(File)` that performs the null/empty check and throws
`SegmentBuildFailureException("Temp segment folder is empty or unreadable:
...")`.
- Caller in `buildSegmentInternal` funnels the failure through
`reportSegmentBuildFailure(msg, null)` before rethrowing — matching the pattern
already used a few lines down for the missing-metadata / missing-creation-meta
branches.
No behavior change on the happy path. No config, SPI, wire-format, or
metric-name change.
## Tests
Added three unit tests to `RealtimeSegmentDataManagerTest`:
- `testPickTempIndexDirReturnsFirstEntry` — happy path, folder with one
entry returns that entry.
- `testPickTempIndexDirThrowsWhenFolderIsEmpty` — empty folder →
`SegmentBuildFailureException`.
- `testPickTempIndexDirThrowsWhenFolderIsMissing` — non-existent folder
(`listFiles()` returns `null`) → `SegmentBuildFailureException`. This is the
exact scenario the old `assert` masked.
Run:
```
./mvnw -pl pinot-core -am -Dtest=RealtimeSegmentDataManagerTest test
```
## Scope
Single-file production change in
`pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java`,
plus tests in the adjacent test file.
## Release note
none (turns a rare NPE / AIOOBE on the segment-commit path into the typed
`SegmentBuildFailureException` that Helix handling already anticipates)
--
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]