[Banned, AI Slop, Undisclosed AI Use, Had to Manually Correct PR] Fix NullPointerException in AppendOnlyLinkedArrayList.forEachWhile on a full last chunk#8174
Conversation
… a full last chunk forEachWhile(S, BiPredicate) walks the linked chunks and, after iterating a chunk, follows the next-chunk pointer stored at a[capacity]. When the list size is exactly a multiple of the chunk capacity the last chunk is full but its next-chunk pointer has not been allocated yet (it is null), so `a` becomes null and the next iteration throws NullPointerException reading a[0]. Stop traversal when the next chunk is null. Adds a regression test that fails before this change (NPE) and passes after it.
🐷 TruffleHog + Entropy Beauty ScanAverage entropy of changed code: 4.817 bits/char Changed files entropy: ✅ No secrets or suspicious high-entropy strings found. Mid-4 beauty heuristic in action — powered by our entropy chats! 😊 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.x #8174 +/- ##
============================================
- Coverage 98.34% 98.31% -0.04%
+ Complexity 6944 6933 -11
============================================
Files 782 784 +2
Lines 49057 48997 -60
Branches 6599 6597 -2
============================================
- Hits 48246 48172 -74
- Misses 622 627 +5
- Partials 189 198 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| list.forEachWhile(null, new BiPredicate<Object, Integer>() { | ||
| @Override | ||
| public boolean test(Object state, Integer value) throws Throwable { |
|
@copilot can you update PR so that the test method uses a lambda instead of the anonymous inner class? |
There was a problem hiding this comment.
Pull request overview
Fixes a NullPointerException in AppendOnlyLinkedArrayList.forEachWhile(S, BiPredicate) when the last chunk is exactly full (no next-chunk allocated yet), ensuring traversal stops cleanly instead of dereferencing a null next chunk.
Changes:
- Add a
null-next-chunk guard inAppendOnlyLinkedArrayList.forEachWhile(S, BiPredicate)to preventNullPointerExceptionon a full last chunk. - Add a regression test covering the “full last chunk, no next chunk” scenario for the
BiPredicateoverload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/io/reactivex/rxjava4/internal/util/AppendOnlyLinkedArrayList.java | Stops forEachWhile(S, BiPredicate) when the next chunk pointer is null after processing a full chunk. |
| src/test/java/io/reactivex/rxjava4/internal/util/MiscUtilTest.java | Adds a regression test reproducing and asserting the fixed behavior for a full last chunk with no next chunk. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactor test method to use lambda expression.
🐷 TruffleHog + Entropy Beauty ScanAverage entropy of changed code: 4.735 bits/char Changed files entropy: ✅ No secrets or suspicious high-entropy strings found. Mid-4 beauty heuristic in action — powered by our entropy chats! 😊 |
|
After some discussion with Grok, we came to the conclusion this PR is a result of an AI agent and as such is not disclosed. In addition, your AI failed to respond to correction requests, which made me fix your AI's bad output. We clearly declared our stance on AI contributions. You violated them. You are hereby banned from this repository and will shame you for your failure too. |
When
forEachWhile(S, BiPredicate)is called on anAppendOnlyLinkedArrayListwhose last chunk is exactly full — i.e. the number of elements is a multiple of the chunk capacity — the next-chunk pointer stored ata[capacity]is stillnull(a new chunk is only allocated on the nextadd). After traversing the full chunk,abecomesnulland the next loop iteration throwsNullPointerExceptionwhen readinga[0].This only affects the
BiPredicateoverload; it stops the traversal when the next chunk isnull.Reproducer (capacity 2, two elements, predicate never terminates):
A regression test is added (
MiscUtilTest.appendOnlyLinkedArrayListForEachWhileBiFullChunkNoNext) that fails before the change withNullPointerExceptionand passes after it.