Skip to content

False positive on JDK 27 #1534

@mpkorstanje

Description

@mpkorstanje

After upgrading error_prone_core to v2.49.0 and nullaway to v0.13.3 together (due to #1511) in junit-team/junit-framework#5589, https://github.com/junit-team/junit-framework/actions/runs/24429467026/job/71370536336?pr=5589 fails on junit-team/junit-framework@bc2ffac with a false positive.

@Override
	public void close() {
		if (!this.closed) {
			try {
				if (this.closeAction != null) {
					List<Throwable> failures = new ArrayList<>();
					this.storedValues.entrySet().stream() //
							.map(e -> EvaluatedValue.createSafely(e.getKey(), e.getValue())) //
							.filter(Objects::nonNull) //
							.sorted(EvaluatedValue.REVERSE_INSERT_ORDER) //
							.forEach(it -> {
								try {
									it.close(this.closeAction);
								}
								catch (Throwable t) {
									UnrecoverableExceptions.rethrowIfUnrecoverable(t);
									failures.add(t);
								}
							});
					if (!failures.isEmpty()) {
						var iterator = failures.iterator();
						var throwable = iterator.next();
						iterator.forEachRemaining(throwable::addSuppressed);
						throw throwAsUncheckedException(throwable);
					}
				}
			}
			finally {
				this.closed = true;
			}
		}
	}

With:

home/runner/work/junit-framework/junit-framework/junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java:146: warning: [NullAway] dereferenced expression it is @Nullable

									it.close(this.closeAction);
									  ^
    (see http://t.uber.com/nullaway )

Here it can not be null because .filter(Objects::nonNull) was applied. The same false positive doesn't show up on JDK 26 and below.

Probably immediately detected once #1525 is resolved, but I didn't want to keep this from you either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions