Skip to content

Address Error Prone warnings gh-72 - #73

Closed
anilvdl wants to merge 6 commits into
spring-ai-community:mainfrom
anilvdl:fix/error-prone-warnings
Closed

anilvdl wants to merge 6 commits into
spring-ai-community:mainfrom
anilvdl:fix/error-prone-warnings

Conversation

@anilvdl

@anilvdl anilvdl commented May 30, 2026

Copy link
Copy Markdown
Contributor

Resolves the Error Prone / NullAway warnings from gh-72 across the reactor - the build now reports zero warnings (./mvnw clean verify green). Mostly mechanical (Javadoc summaries, Locale.ROOT, unused symbols, and a few @SuppressWarnings where the flagged code is intentional).

One behavior change worth flagging: ApiKeyImpl.from() no longer truncates a secret containing . - it now splits on the first . only, with a regression test. Happy to reject malformed keys instead if that's the intended format. Also includes the samples/ warnings; glad to remove them if gh-72 is library-only.

anilvdl added 3 commits May 30, 2026 01:26
Resolve the lint-only Error Prone findings across the library modules:

- MissingSummary: add summary sentences to Javadocs that previously
  contained only an @author tag (api key types, OAuth2 webclient filters,
  configurers, resource identifier, DCR manager test).
- StringCaseLocaleUsage: parse the Cache-Control header with
  toLowerCase(Locale.ROOT).
- CanonicalDuration: suppress on the session timeout field, keeping the
  explicit Duration.ofHours(48) for readability.
- ExtendsObject: drop the redundant `extends Object` type bound.
- EmptyCatch: document why the ClassNotFoundException is ignored.
- InlineMeSuggester: suppress on the deprecated 3-arg DCR manager
  constructor (@InlineMe is not on the classpath).
- TypeParameterUnusedInFormals: suppress on ApiKeyEntity.copy() and on
  getOptionalBean, preserving call-site ergonomics and (for the latter)
  fidelity with the upstream Spring Security helper.
- StringSplitter: suppress on the JWT-payload split in the authorization
  server test (no Guava on the classpath, behaviour is fine).
- UnusedVariable / DefaultCharset: remove the unused SECRET test field and
  its now-unused imports.

Signed-off-by: Anil Kumar Veldurthi <anil.veldurthi@gmail.com>
…munitygh-72

- MissingSummary: add summary sentences to the sample application
  Javadocs.
- UnusedMethod: remove the dead findUniqueClientRegistration helper and
  its now-unused imports.

Signed-off-by: Anil Kumar Veldurthi <anil.veldurthi@gmail.com>
…ring-ai-communitygh-72

ApiKeyImpl.from() previously split the "id.secret" string on every "." and
kept only the first two segments, silently truncating any secret that
contained a ".". A caller presenting the full, correct key would then fail
authentication.

This changes the parsing behavior: the id is now everything before the first
".", and the secret is the entire remainder, so secrets containing "." are
preserved (previously silently truncated). The existing contains(".") guard
keeps the separator index valid.

This is a deliberate behavior change in the API-key authentication path,
not merely the StringSplitter lint cleanup that surfaced it.

Signed-off-by: Anil Kumar Veldurthi <anil.veldurthi@gmail.com>

@Kehrlann Kehrlann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for your contribution!

We have Error Prone in the project for NullAway support, were are not really leveraging the rest of error prone. I'd rather not introduce @SuppressWarnings - in the future, we may have a difference checker for JSpecify,

Let's:

  1. Get rid of all the suppressions
  2. Remove the current warnings from error prone in the maven config

Comment on lines +41 to +44
int separatorIndex = apiKey.indexOf('.');
var id = apiKey.substring(0, separatorIndex);
var secret = apiKey.substring(separatorIndex + 1);
return new ApiKeyImpl(id, secret);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Given that the "surprising behavior" is about ".".split("\\."), I'd say we are safe here and we should revert this.

See: https://errorprone.info/bugpattern/StringSplitter

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do, reverting to split. One check before I do: can the secret half ever contain a .? With split("\\.") a key like id.ab.cd parses the secret as ab (drops cd), whereas the indexOf version kept it as ab.cd. If secrets are dot-free by construction, the revert is clean, and I'll drop the regression test with it.

anilvdl and others added 3 commits June 7, 2026 13:12
…curity/server/apikey/ApiKeyImplTests.java

Co-authored-by: Daniel Garnier-Moiroux <daniel.garnier-moiroux@broadcom.com>
Signed-off-by: Anil Kumar Veldurthi <anil.veldurthi@gmail.com>
@anilvdl

anilvdl commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Kehrlann, review addressed:

  • Dropped all the non-NullAway suppressions and set Error Prone to NullAway-only in the Maven config (-XepDisableAllChecks then -Xep:NullAway:ERROR), so the other checks no longer fire and there's nothing to suppress.
  • Reverted ApiKeyImpl.from() to split as suggested, and removed the dot-preservation test along with it.
  • Applied the copyright suggestion.

One suppression left in place: @SuppressWarnings("NullAway") on fromNullThrows, which intentionally passes null to verify from(String) rejects it. Happy to drop it and exclude src/test from NullAway instead if you'd prefer that. Re-requested review.

@anilvdl
anilvdl requested a review from Kehrlann June 14, 2026 07:44
@Kehrlann

Copy link
Copy Markdown
Collaborator

Conflicts resolved and merged in e525488

Thanks for your contribution!

@anilvdl

anilvdl commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review and merge @Kehrlann, learned a lot from the feedback. Looking forward to contributing more.

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.

2 participants