Skip to content

refactor(startup): rotate ascii banners, drop the 1s startup sleep (#36887) - #36888

Open
wezell wants to merge 4 commits into
mainfrom
issue-asciiart-startup-banners
Open

refactor(startup): rotate ascii banners, drop the 1s startup sleep (#36887)#36888
wezell wants to merge 4 commits into
mainfrom
issue-asciiart-startup-banners

Conversation

@wezell

@wezell wezell commented Aug 4, 2026

Copy link
Copy Markdown
Member

Fixes #36887

Summary

Cosmetic startup change with one real win: doArt() no longer sleeps for a second on every boot.

Before After
private static boolean artDone + check-then-set AtomicBoolean.compareAndSet — two racing threads can't both print
One hardcoded banner 7 banners, one picked per boot
Thread.sleep(1000) gone — a second back on every startup

Note for reviewers: text blocks and backslashes

Java text blocks still process escape sequences, so ASCII art containing \ does not compile as-is:

error: illegal escape character
 \     .'_  .-'),-----. /     '._  .-----.
  ^

Every backslash in the art is escaped as \\, and \s is used where a trailing space must survive (text blocks strip incidental trailing whitespace). If you add a banner, run it through javac before pushing.

Verification

Compiled the class standalone against a stub Logger and rendered all 7 banners — output is byte-identical to the source art, including the trailing spaces preserved by \s.

Checklist

  • Docs — n/a (no config or API surface)
  • Translations — n/a
  • Security considered — log output only, no input
  • Tests — none added; it's a startup banner with no logic worth pinning

🤖 Generated with Claude Code

…36887)

- Replaces the single hardcoded banner with a rotating set of 7, picked
  per boot.
- artDone becomes an AtomicBoolean with compareAndSet, closing the
  check-then-set race that could let two threads both print.
- Removes Thread.sleep(1000) from doArt(), giving back a second on every
  startup.

Backslashes in the art are escaped (\\) because Java text blocks still
process escape sequences; \s marks trailing spaces that text blocks would
otherwise strip.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

❌ Linked Issue Needs Team Label

This PR is linked to issue #36887, but that issue has no Team : * label. Every linked issue must be owned by a team for tracking and triage.

How to fix this:

Apply a Team : * label to the linked issue (e.g., Team : Scout, Team : Platform, Team : Falcon, Team : Maintenance). Then push a new commit or edit the PR description to re-run this check.


This comment was automatically generated by the issue linking workflow

@claude

claude Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Claude finished @wezell's task in 2m 29s —— View job


Code Review

Reviewed the diff against origin/main. Verified: ascii-art.txt has 6 %%% separators → 7 banners (matches the PR description), the only caller is ContextLifecycleListener.java:23, and the resource lives under src/main/resources so it ships on the classpath.

New Issues

No blocking issues found. Two minor notes below, neither blocks merge.

  • 🟡 Medium: AsciiArt.java:23-30compareAndSet(false, true) runs before load(). If the resource is ever missing or unreadable on the first call, artDone is already latched to true, so the banner is silently skipped forever (no retry on later calls). This is harmless for a cosmetic banner and arguably intentional, but worth a one-line comment noting the ordering is deliberate so a future reader doesn't "fix" it.

  • 🟡 Medium: AsciiArt.java:18,46SEPARATOR = "\n%%%\n" is passed to String.split(...), which interprets it as a regex. It works today only because % and \n have no special regex meaning. If the separator token ever changes to something with regex metacharacters (., |, *, etc.) this breaks silently. Consider Pattern.quote(SEPARATOR) or a literal-split helper to make the intent explicit. Fix this →

Notes (non-issues, verified OK)

  • art[(int)(System.currentTimeMillis() % art.length)]long % int promotes to long, result is always in [0, art.length-1], and currentTimeMillis() is non-negative, so the cast to int and the index are safe.
  • AtomicBoolean.compareAndSet correctly closes the check-then-set race the old boolean artDone had — two racing threads can no longer both print.
  • load() handles both the null-stream and IOException cases by returning an empty array, and doArt() early-returns on empty. Failure path is contained.
  • Dropping Thread.sleep(1000) is a straight win with no dependents (only caller is ContextLifecycleListener).
  • Config/Logger used correctly; no System.out/getProperty/getenv. Log-output-only, no input — no security surface.

Unrelated to the code: the CI comment flags that linked issue #36887 needs a Team : * label — that's a triage/label action, not a code change.

Overall this does what the description says and is safe to merge. The two medium notes are optional polish.
· issue-asciiart-startup-banners

@github-actions github-actions Bot added the Area : Backend PR changes Java/Maven backend code label Aug 4, 2026
wezell and others added 3 commits August 4, 2026 18:40
…getenv

Banner 1 was tab-indented. Java text blocks strip one tab as incidental
whitespace, and the terminal expands each remaining tab to 8 columns, so
the top rows were shoved right relative to the rest of the art. Converted
to plain spaces.

The art also started on the same line as the log prefix, offsetting the
first row by ~30 characters. Extracted a print() helper that emits leading
newlines so the banner starts in column 0.

Replaced System.getenv("DOT_SHOW_ALL_ASCII_ART") with
Config.getBooleanProperty("SHOW_ALL_ASCII_ART", false) per the Config/Logger
rule; Config resolves it from the same DOT_-prefixed env var, so existing
usage is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
doArt() runs exactly once, guarded by the AtomicBoolean, so there is no
reason to keep the banner array reachable for the life of the JVM. Clear it
on the way out and make the field private.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The banners lived in text blocks, which meant every backslash had to be
escaped as \\ and every trailing space marked with \s — easy to get wrong,
and the literals stayed interned in the class constant pool for the life of
the JVM regardless of clearing the array.

Moved the art to /ascii-art.txt, banners separated by a %%% line, and load
it once in doArt(). The art is plain text (single backslashes, real trailing
spaces) and is garbage once doArt() returns. A missing or unreadable
resource skips the banner rather than breaking startup.

Verified the resource round-trips identically to the old text blocks: 7
banners, no tabs, backslash-heavy art literal, trailing spaces intact.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

AsciiArt startup banner: drop the 1s sleep, fix the once-only race, rotate banners

1 participant