Skip to content

Conversation

@Kaustav-Sarkar
Copy link

GH-399 Fix setPosition fails with NullPointerException

Fixed a NullPointerException in DenseUnionWriter#setPosition.

The issue was that setPosition tried to update all writers in its internal array, even if they hadn't been initialized yet. I added a null check so it only updates writers that actually exist.

Also added a regression test (TestDenseUnionWriterNPE) to verify the fix and updated .gitignore.

Closes #399.

Added null checks for setPosition and test cases to validate the issue
@Kaustav-Sarkar Kaustav-Sarkar changed the title GH-399 Fix setPosition fails with NullPointerException GH-399: Fix setPosition fails with NullPointerException Dec 24, 2025
@github-actions

This comment has been minimized.

@Kaustav-Sarkar
Copy link
Author

I do not have permissions to set labels

❯ gh pr edit 938 --add-label "bug-fix"

GraphQL: Kaustav-Sarkar does not have the correct permissions to execute `AddLabelsToLabelable` (addLabelsToLabelable)

@lidavidm lidavidm added the bug-fix PRs that fix a big. label Dec 25, 2025
@github-actions github-actions bot added this to the 18.4.0 milestone Dec 25, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class TestDenseUnionWriterNPE {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: JUnit 5 doesn't require declaring everything public

}

@Test
public void testListOfDenseUnionWriterNPE() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link back to the issue

Suggested change
public void testListOfDenseUnionWriterNPE() {
public void testListOfDenseUnionWriterNPE() {
// Regression test for ...

@lidavidm lidavidm changed the title GH-399: Fix setPosition fails with NullPointerException GH-399: Check for null writers in DenseUnionWriter#setPosition Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java] DenseUnionWriter#setPosition fails with NullPointerException

2 participants