GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [core] chore: Report unprocessed files in DeterministicOutputListenerWrapper by shivampwm2020 · Pull Request #7181 · pmd/pmd

Conversation

@shivampwm2020

@shivampwm2020 shivampwm2020 commented Oct 14, 2026 •
edited by zbynek
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Describe the PR

Fixes a misleading AssertionError that hides the real cause of a failed analysis.

Problem

Under some analysis/parallel conditions PMD fails with:

java.lang.AssertionError: Closed listener but not all files have been processed
    at net.sourceforge.pmd.reporting.DeterministicOutputListenerWrapper.close(DeterministicOutputListenerWrapper.java:131)

This AssertionError carries no information about what went wrong, so it masks the
actual failure that produced it.

Root cause

DeterministicOutputListenerWrapper.close() (pmd-core/src/main/java/net/sourceforge/pmd/reporting/DeterministicOutputListenerWrapper.java:126-131)
asserts that its report buffer is empty. The buffer is only empty if every file's
report was delivered in order.

Reports are delivered by the parallel analysis jobs, which are joined in
PmdAnalysis.performAnalysisImpl (pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java:455-459):

} finally {
    Exception e = IOUtil.closeAll(analyses);
    if (e != null) {
        reporter.errorEx("Error while joining analysis", e);
    }
}

If joining the analysis jobs fails, that error is reported but not propagated.
Execution then falls through to the surrounding finally (line 465), which calls
listener.close(). Because the unjoined jobs never delivered their reports, the
buffer is still non-empty and the wrapper asserts — the user sees the opaque
AssertionError instead of the join error that actually caused it.

Fix

Keep the assertion (it is a genuine invariant), but make it self-explaining:
include the file ids that were declared but never processed, so the error points
at the real problem and at the files that never produced reports. This is a
one-concern change with no happy-path behaviour change.

Related issues

  • [core] AssertionError in DeterministicOutputListenerWrapper.close() under high file/violation count with multithreading #6869

Testing

RED on main (fix reverted, test kept):

$ ./mvnw -o -pl pmd-core test -Dtest=DeterministicOutputListenerWrapperTest
[ERROR] closeNamesUnprocessedFilesWhenReportsAreMissing() <<< FAILURE!
org.opentest4j.AssertionFailedError: Expected the error to name the unprocessed files,
  got: Closed listener but not all files have been processed
    at DeterministicOutputListenerWrapperTest.closeNamesUnprocessedFilesWhenReportsAreMissing(...)
[ERROR] Tests run: 11, Failures: 1, Errors: 0, Skipped: 0

GREEN with the fix:

$ ./mvnw -o -pl pmd-core test -Dtest=DeterministicOutputListenerWrapperTest
BUILD SUCCESS
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0

The new test closeNamesUnprocessedFilesWhenReportsAreMissing drives the wrapper
directly: two files are declared, only the second file's report is delivered (so
the first stays buffered), then close() is called and must name both unprocessed
files.

Regression sweep (renderer / analysis / listener tests in pmd-core):

$ ./mvnw -o -pl pmd-core test -Dtest='*Renderer*,PmdAnalysisTest,*Deterministic*,*Listener*'
Tests run: 352, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

The full ./mvnw clean verify across all modules was not run.

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Shivam Maurya
[core] Report unprocessed files in DeterministicOutputListenerWrapper
f00e6cc
When the parallel analysis jobs are not joined successfully (for example
because joining them failed and the error was only reported, not
propagated), some file reports never reach the wrapper. Its close() then
threw a bare AssertionError with no information, hiding the actual cause
of the failure.

Include the file ids that were declared but never processed in the
message, so the real problem is visible.

Fixes pmd#6869
@zbynek

zbynek commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

I changed the description to only mention #6869 and not consider this PR a fix for that issue, since this just extends logging.

It might be useful to split the list of files that are reported as not processed in two: the ones in the buffer and the rest.

adangel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel added the a:bug PMD crashes or fails to analyse a file. label Nov 5, 2026
adangel
adangel reviewed Nov 5, 2026
View reviewed changes
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/reporting/DeterministicOutputListenerWrapper.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adangel
Merge branch 'main' into pr-7181
a70e23e
@adangel adangel added an:enhancement An improvement on existing features / rules in:pmd-internals Affects PMD's internals and removed a:bug PMD crashes or fails to analyse a file. labels Nov 5, 2026
@adangel adangel changed the title [core] Report unprocessed files in DeterministicOutputListenerWrapper [core] chore: Improve assertion message for unprocessed files in DeterministicOutputListenerWrapper Nov 5, 2026
@adangel
[core] DeterministicOutputListenerWrapper: Improve assertion message
0d7244a
Only output first 10 file names, use two groups: unfinished files
and buffered files
@adangel adangel added this to the 7.30.0 milestone Nov 5, 2026
@adangel adangel changed the title [core] chore: Improve assertion message for unprocessed files in DeterministicOutputListenerWrapper [core] chore: Report unprocessed files in DeterministicOutputListenerWrapper Nov 5, 2026
@pmd-actions-helper

pmd-actions-helper Bot commented Nov 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-11-05 15:42:24+00:00 for 5267055)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel @claude
[core] DeterministicOutputListenerWrapper: Clean up assertion message…
5267055
… code

- Fix comments and javadoc: the original Error is propagated, but
  replaced by the AssertionError; describe the two groups of files
- Extract describeGroup() and make MAX_FILES_IN_MESSAGE a constant
- Find unprocessed files by index instead of comparing paths
- Tests: use GlobalAnalysisListener.noop(), clearer names, no gap in
  the file indexes, split long expected strings

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adangel
adangel merged commit 62adac6 into pmd:main Nov 5, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel mentioned this pull request Nov 5, 2026
[core] Fix #6869: Don't hide analysis Error behind AssertionError #7296
Open
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

an:enhancement An improvement on existing features / rules in:pmd-internals Affects PMD's internals

Projects

None yet

Milestone

7.30.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@shivampwm2020 @zbynek @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.