Skip to content

GH-130: Fix AutoCloseables to work with @Nullable structures - #1017

Merged
jbonofre merged 1 commit into
apache:mainfrom
axreldable:ARROW-130-checker-framework-autocloseables-annotations
Feb 17, 2026
Merged

GH-130: Fix AutoCloseables to work with @Nullable structures#1017
jbonofre merged 1 commit into
apache:mainfrom
axreldable:ARROW-130-checker-framework-autocloseables-annotations

Conversation

@axreldable

@axreldableaxreldable commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

What's Changed

AutoCloseables supposes to work with nullable Iterables, varargs, and collection of nulls. The PR introduces:

  • @Nullable annotation for all public methods in AutoCloseables (only private flatten method doesn't support null Iterable)
  • null checks to prevent NPEs

The change is backward compatible. Only possible NPEs are prevented.


Closes#130 .

@github-actions

This comment has been minimized.

@axreldable

Copy link
Copy Markdown
ContributorAuthor

Please add the enhancement label.

@lidavidmlidavidm added the enhancement PRs that add or improve features. label Feb 13, 2026
@github-actionsgithub-actionsBot added this to the 19.0.0 milestone Feb 13, 2026
@axreldable
axreldableforce-pushed the ARROW-130-checker-framework-autocloseables-annotations branch from 338980c to d5c317cCompareFebruary 16, 2026 19:31

@jbonofrejbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't have problem to add @Nullable. That said, I don't consider as a bug fix but more as improvement.

*/
public static AutoCloseable all(final Collection<? extends AutoCloseable> autoCloseables) {
public static AutoCloseable all(
final @Nullable Collection<? extends @Nullable AutoCloseable> autoCloseables) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't have problem to add @Nullable here.

public static void close(Throwable t, AutoCloseable... autoCloseables) {
public static void close(Throwable t, @Nullable AutoCloseable... autoCloseables) {
if (autoCloseables == null) {
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That should not happen, but it seems you have a case ;)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, they are saying it's not overly cautious.
https://stackoverflow.com/a/28271272/8269828

@jbonofre
jbonofre merged commit 3298443 into apache:mainFeb 17, 2026
26 checks passed
@axreldable
axreldable deleted the ARROW-130-checker-framework-autocloseables-annotations branch February 26, 2026 21:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementPRs that add or improve features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java] Checker Framework annotations for AutoCloseables in arrow-memory-core are incorrect

3 participants

@axreldable@jbonofre@lidavidm