Skip to content

fix: resolve ErrorProne StringSplitter warnings - #366

Closed
franvila wants to merge 2 commits into
mainfrom
fix/05049-stringsplitter-errorprone
Closed

franvila wants to merge 2 commits into
mainfrom
fix/05049-stringsplitter-errorprone

Conversation

@franvila

@franvila franvila commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Type of change

  • Refactoring

Description

Replace all String.split(regex) and Pattern.split(input) calls with their two-argument form passing -1 as the limit. This makes the splitting behavior explicit by preserving trailing empty strings, which is what ErrorProne's StringSplitter check requires.

This resolves all 22 StringSplitter warnings across 10 files without introducing Guava's Splitter or adding @SuppressWarnings annotations.

Affected modules:

  • kroxylicious-runtime (HostPort)
  • kroxylicious-openmessaging-benchmarks (RunMetadata, ResultComparatorTest)
  • kroxylicious-integration-tests (ExpositionIT, ProxyProtocolIT, RoutingContextContractIT, SaslTerminationOauthBearerIT, AbstractAuthzEquivalenceIT, AuthzIT)
  • kroxylicious-systemtests (Environment, Exec, DeploymentUtils, KafkaVersionUtils)

Additional Context

The String.split(String) method silently discards trailing empty strings, which can lead to surprising behavior. Passing -1 as the limit makes the behavior explicit and predictable. See https://errorprone.info/bugpattern/StringSplitter.

Checklist

  • New tests written (where applicable).
  • If making a user-facing change, documentation is provided, or if the intent is to provide documentation in a follow up PR, an issue is raised tracking the need for the documentation update. Link the to issue in this checklist.
  • Existing unit/integration/system tests passing.
  • Any Sonarcloud warnings are addressed (or suppressed with @SuppressWarnings and a justifying comment).
  • PR references related GitHub issue(s) so they are closed on merging.
  • If AI tools assisted with code changes, ensure commit messages include Assisted-by: trailer (see DEV_GUIDE.md).
  • For user facing changes, add a logchange entry YAML file to changelog/unreleased/ (remember to include changes affecting the API of the test artefacts too). See DEV_GUIDE.md for the entry format.

🤖 Generated with Claude Code

Replace String.split(regex) and Pattern.split(input) calls with their
two-argument form passing -1 as the limit, which makes the splitting
behavior explicit by preserving trailing empty strings. This addresses
all 22 ErrorProne StringSplitter warnings across 10 files without
requiring Guava's Splitter or suppression annotations.

Fixes: kroxylicious#5025
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Francisco Vila <fvila@redhat.com>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Francisco Vila <fvila@redhat.com>
@franvila
franvila force-pushed the fix/05049-stringsplitter-errorprone branch from ac4e6e5 to 4283256 Compare October 8, 2026 11:34
@franvila franvila closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant