Improve error reporting#1983
Conversation
Add unit tests to check error reporting
gnodet
left a comment
There was a problem hiding this comment.
Nice work on the error-reporting improvements, @kwin — the continue-on-error pattern with precise DocTreePath locations is a big UX improvement for developers debugging their javadoc tags. The DocTreePathAwareRuntimeException is a clean solution, and I especially like that you fixed the pre-existing bug where extractClassLink hardcoded "@configurationDefaultValue" in error messages even when called for the @configurationType tag.
One thing caught my attention:
Behavioral regression: fields without @configurationDefaultValue are now silently dropped
In processResolverField, the new null guard:
String defValue = resolveDefaultValue(type, field, docComment, blockTags.get("configurationDefaultValue"));
if (defValue == null) {
// Error was already reported, skip this field
return;
}changes behavior for fields that have @configurationSource but no @configurationDefaultValue tag. On master, resolveDefaultValue returned null for a missing tag, but the field was still included via nvl(defValue, "") producing an empty default value string. After this PR, the field is silently skipped.
This affects real configuration keys in the codebase — a quick check shows at least:
| File | @configurationSource |
@configurationDefaultValue |
|---|---|---|
ClasspathTransporterFactory.java |
1 | 0 |
DefaultOfflineController.java |
3 | 0 |
GnupgConfigurationKeys.java |
5 | 4 |
The comment "Error was already reported" is also not accurate — when contentTag is null (tag absent), resolveDefaultValue returns null silently without reporting anything.
Suggested fix: remove the if (defValue == null) return; guard and keep the original nvl(defValue, "") handling when building the entry. The null return from resolveDefaultValue for a missing tag is a valid "no default" case, not an error. The actual error case (unresolvable link) already throws DocTreePathAwareRuntimeException and is caught by the per-field catch blocks.
Minor nits:
- There's a stray blank line in
extractClassLinkbetween theifcondition and thethrowstatement - The top-level
run()catch lost the stack trace (e.printStackTrace(reporter.getStandardWriter())was removed) — for truly unexpected failures (NPEs, etc.), the stack trace is valuable for diagnosis
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
And as can be seen on 2.0.21 release: https://maven.apache.org/resolver-archives/resolver-LATEST/configuration.html Not all "Source" (last column) values are handled, there are some uninterpolated values left.
Unsure is this help or renderer issue, but it should be replaced with "Java System Properties", as currently Resolver config is sourced from two places:
|
|
Thanks for the follow-up commit, @kwin — the "Don't skip field without default values" fix directly addresses the behavioral regression I flagged in my review. Verified: The rest of the changes (continue-on-error pattern with This comment was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying. |
gnodet
left a comment
There was a problem hiding this comment.
Solid error-reporting improvement. The continue-on-error pattern with precise DocTreePath locations is a well-designed improvement over the fail-fast approach. Good test coverage with CapturingDiagnosticsListener.
The second commit correctly fixed the behavioral regression where fields without @configurationDefaultValue were being silently dropped. CI passes across all matrix combinations.
Minor observations (not blockers):
- The generic
RuntimeExceptioncatch block (line 169) constructs aDocTreePathwithdocComment, butdocCommentcan be null when processing maven-mode fields — a guard would prevent masking the real error with an NPE. - The
run()catch block no longer prints stack traces for unexpected failures — worth preserving for diagnostic value. - Stray blank line in
extractClassLink(line 480) and minor javadoc typo in the test ("the a fixture" → "a fixture").
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet

Add unit tests to check error reporting
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
mvn -Prun-its verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.