Skip to content

fix: preserve braces in Javadoc code tags - #1218

Open
efegokdemir wants to merge 4 commits into
apache:masterfrom
efegokdemir:codex/issue-823-curly
Open

efegokdemir wants to merge 4 commits into
apache:masterfrom
efegokdemir:codex/issue-823-curly

Conversation

@efegokdemir

Copy link
Copy Markdown

Summary

Preserve closing braces inside {@code ...} content when legacy Javadoc tags are converted to XHTML. This prevents expressions such as ${project.basedir} from prematurely terminating the inline tag.

Changes

  • Allow balanced braces in the Javadoc inline-tag matcher.
  • Add a regression test covering nested braces in a multiline code block.

Testing

  • mvn -pl maven-plugin-tools-generators -am -Dspotless.apply.skip=true -Dspotless.check.skip=true -Dcheckstyle.skip=true -Drat.skip=true test — passed (61 API tests; 18 generator tests, 1 skipped)
  • git diff --check — passed

spotless:check was attempted but is blocked by the local JDK/Palantir formatter incompatibility (NoSuchFieldError in JCTree$JCCompilationUnit).

Fixes #823

@slachiewicz slachiewicz added the bug Something isn't working label Oct 29, 2026
efegokdemir and others added 2 commits October 30, 2026 02:52
Track balanced braces and escaped delimiters when decoding legacy inline tags. Add a regression covering nested property expressions and adjacent Javadoc tags.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Correct fix for the brace-nesting bug in decodeJavadocTags().

Pre-fix test validation: ✅ 2 of 4 new tests (decodeJavadocCodeWithNestedClosingBrace, decodeJavadocCodeWithMultipleLevelsOfNestedBraces) fail against the base code and pass with the fix. All 21 module tests pass.

Analysis:

  • findInlineTagEnd() brace-counting correctly matches javac's doclet behavior. Backslashes are literal in Javadoc (not escape characters) — \{ increments depth and \} decrements it, so the test for \{braces\} content is correct.
  • quoteReplacement() removal is safe: the old helper was only needed to suppress $/\ special-meaning in appendReplacement(), which is no longer called. Direct decoded.append(text) has no such interpretation.
  • Skip-on-unmatched-brace logic (searchFrom = matcher.start() + 2) is correct — advances past {@ without risking re-match of the same position.
  • StringBuffer → StringBuilder: decodeJavadocTags() is not shared across threads; the change is safe.

Note: The same bug exists in the maven-plugin-tools-3.x branch (same quoteReplacement/appendReplacement pattern). Consider opening a backport PR for milestone 3.16.1.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MPLUGIN-513] Closing curly brace in code block rendered incorrectly

3 participants