Repository navigation
Issue #5895: Finish file and audit reports after processing failures - #21520
Conversation
af615f6 to
f05bd0e
Compare
|
Please read and watch playlist videos at Starting_Development. |
f05bd0e to
0465b61
Compare
arturict
left a comment
There was a problem hiding this comment.
ran CheckerTest, XMLLoggerTest, MainTest, SarifLoggerTest and DefaultLoggerTest against this head on linux, 226 pass. the try-with-resources instead of a plain finally is what keeps the processing failure as the primary exception when a listener also throws, and testProcessingExceptionPreservedWhenCompletionFails pins exactly that, so the extra interface earns its place.
|
Pitest must be resolved by extra test coverage |
| import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.getExpectedThrowable; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.doThrow; | ||
| import static org.mockito.Mockito.mock; |
There was a problem hiding this comment.
Sorry , no mockito.
Use real classes
There was a problem hiding this comment.
Removed Mockito. The completion-failure regression now uses a concrete DefaultLogger subclass, and the cached-file regression uses the existing counting logger with a fileFinished counter. Rebased onto current master in 07e0ba0. Full local verification passed before the rebase; the rebased local pitest-common run detects all 1,835 mutations with none surviving. All 133 remote checks now pass, including pr-age.
a3fbd98 to
07e0ba0
Compare
|
|
||
| /** Completion notification that preserves processing failures during resource cleanup. */ | ||
| @FunctionalInterface | ||
| private interface AuditCompletion extends AutoCloseable { |
There was a problem hiding this comment.
name it FileAuditCompletion as it is file based, not whole Audit.
| fireAuditStarted(); | ||
| for (final FileSetCheck fsc : fileSetChecks) { | ||
| fsc.beginProcessing(charset); | ||
| } | ||
| final int errorCount; | ||
| try (AuditCompletion ignored = this::fireAuditFinished) { | ||
| for (final FileSetCheck fsc : fileSetChecks) { |
There was a problem hiding this comment.
this reads in very weird way, even technically it does it job.
please reuse private interface AuditCompletion extends AutoCloseable to make fireAuditStarted when AuditCompletion is started and fireAuditFinished on close.
07e0ba0 to
7875c05
Compare
|
@romani Addressed both review points in commit
The focused 226-test suite, Error Prone, lock checker, and source/resource/example checks pass locally. |
|
The fresh CircleCI run found one PMD-only issue in the reviewer-requested try-with-resources form: Commit |
566cd88 to
7b2b99e
Compare
|
The The replacement check now passes: CircleCI git-check-single-commit. The PR currently has one commit and is mergeable. |
7b2b99e to
45d3e94
Compare
|
@romani Addressed the latest review in Also corrected the squashed commit message that caused Clean |
da65209 to
ce58255
Compare
| * @noinspectionreason MethodOnlyUsedFromInnerClass - notification methods are also | ||
| * tested directly through reflection in CheckerTest. | ||
| */ | ||
| private void fireAuditStarted() { |
There was a problem hiding this comment.
| * deliver filename that was under processing. | ||
| * @noinspection NestedTryStatement, ProhibitedExceptionThrown | ||
| * @noinspectionreason NestedTryStatement - the inner resource completes file notifications | ||
| * before the outer handlers remove failed files from the cache and wrap failures. |
There was a problem hiding this comment.
Sounds like false positive from inspection, as our case has no catch and finally
ce58255 to
300eb1f
Compare
| * @noinspectionreason ProhibitedExceptionThrown - There is no other way to | ||
| * deliver filename that was under processing. | ||
| * @noinspection NestedTryStatement, ProhibitedExceptionThrown | ||
| * @noinspectionreason NestedTryStatement - the inner try-with-resources has no catch or |
There was a problem hiding this comment.
Please create issue against idea inspection, to update explain national comment that it is defect in inspection that eventually be fixed
300eb1f to
7b70811
Compare
| * deliver filename that was under processing. | ||
| * @noinspection NestedTryStatement, ProhibitedExceptionThrown | ||
| * @noinspectionreason NestedTryStatement - false positive: the inner try-with-resources | ||
| * has no catch or finally to merge. Remove this suppression when the inspection is fixed. |
There was a problem hiding this comment.
please share ticket number here that you created against inspection
There was a problem hiding this comment.
Created IDEA-393895. JetBrains has triaged it under Java. Inspections. Updated the suppression explanation in 13c2ba2 to link the ticket and state that the suppression can be removed when the inspection is fixed.
13c2ba2 to
bd56220
Compare
|
Qodana Code Quality Brief Issues Report You can only ticket number, not a url |
bd56220 to
0dc9916
Compare
0dc9916 to
6cf0da5
Compare
Issue: #5895
A processing exception bypasses
fileFinishedandauditFinished, leaving XML output incomplete or unflushed. This is reproducible on Checkstyle 14.1.0 with a syntax error (class Broken {), aTreeWalkercontainingMethodLength, and CLI options-f xml -o results.xml: the command fails and leaves a zero-byte report.Use try-with-resources to finish the audit and each file whose start notification completed. Preserve the original processing failure when completion listeners also throw, attaching cleanup failures as suppressed exceptions. Cached and filtered files do not receive completion notifications. The failing CLI example retains its failure exit code while producing a complete XML report with a file entry.
Add regression tests for XML completion after a check exception and preservation of the original failure when both completion listeners throw. Extend the existing simulated JVM-error/cache test to verify XML completion. Use concrete logger classes for the regressions, and assert that a cached file receives only one completion event. The original XML-completion regression fails before the production change and passes afterward.
Update the Checker Framework baseline for the two private
AutoCloseable.close()receiver-type warnings. These completion resources are local to processing and introduce no shared locking state. The branch also includes upstream's PMD integration-test repair; this PR makes no CI-script changes.The nested-try inspection false positive is tracked in IDEA-393895. The suppression explanation links this issue and documents when it can be removed.
Validation on Java 21:
./mvnw --no-transfer-progress clean verifypassed: 6,828 unit tests (two skipped) and 1,367 integration tests, with zero failures or errors.verify -Dexec.skip=truepassed again after rebasing ontof81aca7, with the same test totals and all verification checks passing. This run reused the previously generated sources.bd56220. Fresh CI is running after the rebase; the PR remains a single commit.Report finalization remains best effort if the process terminates or output/listener implementations fail.
Codex assisted with reproduction, implementation, and validation.