Skip to content

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

Merged
jbonofre merged 1 commit intoapache: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 intoapache:mainfrom
axreldable:ARROW-130-checker-framework-autocloseables-annotations

Conversation

@axreldable
Copy link
Contributor

@axreldable axreldable commented Feb 12, 2026

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
Contributor Author

Please add the enhancement label.

@lidavidm lidavidm added the enhancement PRs that add or improve features. label Feb 13, 2026
@github-actions github-actions bot added this to the 19.0.0 milestone Feb 13, 2026
@axreldable axreldable force-pushed the ARROW-130-checker-framework-autocloseables-annotations branch from 338980c to d5c317c Compare February 16, 2026 19:31
Copy link
Member

@jbonofre jbonofre left a comment

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
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
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
Contributor Author

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:main Feb 17, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PRs 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