Skip to content

Fix predefined ANSI styles in JAnsiTextRenderer - #4259

Open
kalayciburak wants to merge 1 commit into
apache:2.xfrom
kalayciburak:fix/predefined-ansi-styles
Open

Fix predefined ANSI styles in JAnsiTextRenderer#4259
kalayciburak wants to merge 1 commit into
apache:2.xfrom
kalayciburak:fix/predefined-ansi-styles

Conversation

@kalayciburak

Copy link
Copy Markdown
Contributor

Fixes #4254.

Style=Spock and Style=Kirk never applied: AnsiEscape.createMap stores keys in root upper-case, but JAnsiTextRenderer looked up mixed-case special tokens (Style, BeginToken, EndToken) and merged predefined maps with mixed-case names such as Name. Lookups then fell through to createSequence("Name") and rendered an empty SGR. Predefined entry() values were also concatenated without ; separators or a trailing m.

This change:

  • treats ignore-keys in createMap as case-insensitive
  • reads the upper-case special tokens and merges predefined style names in root upper-case
  • builds predefined style sequences with AnsiEscape.createSequence

Test

Executed:

JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 ./mvnw -pl log4j-core-test -am test -Dtest=JAnsiTextRendererTest -Dsurefire.failIfNoSpecifiedTests=false

JAnsiTextRendererTest: 7 tests, 0 failures (RED then GREEN for the Spock/Kirk cases).

Checklist

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • Focused JAnsiTextRendererTest passed as above
  • Changelog entry in src/changelog/.2.x.x
  • Tests are provided

Style=Spock and Style=Kirk never applied because special-token keys
were mixed-case while createMap stores upper-case keys, and predefined
style maps kept mixed-case names. Also emit valid SGR sequences from
entry().

Fixes apache#4254

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Predefined ANSI styles (Style=Spock, Style=Kirk) never apply

1 participant