Skip to content

Prevent PigLatin crashes on empty whitespace tokens - #113

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-piglatin-crash-on-empty-tokens
Closed

Prevent PigLatin crashes on empty whitespace tokens#113
krotname wants to merge 1 commit into
mainfrom
codex/fix-piglatin-crash-on-empty-tokens

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Fix a crash in kyu5.PigLatin.pigIt where splitting on whitespace can produce empty tokens that reach substring(1)/charAt(0) and throw StringIndexOutOfBoundsException for empty input, leading spaces, or consecutive spaces.

Description

  • Add an explicit empty-token guard in src/main/java/kyu5/PigLatin.java with if (w.isEmpty()) continue; before performing the Pig Latin transformation.
  • Preserve existing behavior for punctuation by keeping the !w.matches("\\W") branch and appending punctuation tokens unchanged.
  • Add a regression test handlesEmptyTokensWithoutThrowing in src/test/java/kyu5/PigLatinTest.java that covers empty input, leading whitespace, and consecutive whitespace.
  • Commit message: Handle empty Pig Latin tokens safely.

Testing

  • Ran mvn -q -Dtest=PigLatinTest test and the PigLatin test passed successfully.
  • Ran mvn -q test and the full test suite passed successfully.
  • Ran mvn -q verify and verification (including checks) completed successfully.
  • Ran git diff --check and workspace status checks showed no issues.

Codex Task

@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the validated combined merge in #115: #115

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-piglatin-crash-on-empty-tokens branch August 1, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant