Repository navigation
Conversation
Sonar flagged four call sites that invoke Optional#get() without a
preceding presence check, any of which would throw a runtime
NoSuchElementException if the Optional is empty (rule java:S3655).
Each site is now guarded using the codebase's existing convention of
'Optional<T> xxxOpt = ...; if (xxxOpt.isPresent()) { ... }'.
- minions/async KafkaProducerManager#renderEventMessageHeaders (L226):
wrap header value extraction in an isPresent guard so headers with
no values are simply skipped instead of crashing the producer.
- webapp TestRunnerService#runTests (L200): if a TestCaseResult
references an operation that no longer exists on the service, log
a warning and skip that test case rather than aborting the entire
test run with NoSuchElementException.
- webapp ExamplesExporter#exportHeaders (L174): wrap header value
extraction in an isPresent guard so headers with no values are
omitted from the exported document instead of crashing the export.
- webapp SchemaConformanceAssertion#assertResponse (L63): if no WSDL
resource is available for a SOAP service, log a warning and return
AssertionStatus.FAILED with a clear error message rather than
crashing the assertion.
The happy path is unchanged in every case; only the previously
unreachable empty-Optional path now degrades gracefully.
Signed-off-by: Git-HimanshuRathi <[email protected]>
lbroudoux
approved these changes
May 4, 2026
lbroudoux
left a comment
Member
There was a problem hiding this comment.
Awesome! Thanks a lot! LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sonar flagged four call sites that invoke
Optional#get()without a preceding presence check (rulejava:S3655). Any of these would throwNoSuchElementExceptionat runtime if the Optional is empty. Each site is now guarded using the codebase's existing convention ofOptional<T> xxxOpt = ...; if (xxxOpt.isPresent()) { ... }.Description
minions/async—KafkaProducerManager#renderEventMessageHeaders(L226): wrap header value extraction in anisPresentguard so headers with no values are simply skipped instead of crashing the producer.webapp—TestRunnerService#runTests(L200): if aTestCaseResultreferences an operation that no longer exists on the service, log a warning and skip that test case rather than aborting the entire test run withNoSuchElementException.webapp—ExamplesExporter#exportHeaders(L174): wrap header value extraction in anisPresentguard so headers with no values are omitted from the exported document instead of crashing the export.webapp—SchemaConformanceAssertion#assertResponse(L63): if no WSDL resource is available for a SOAP service, log a warning and returnAssertionStatus.FAILEDwith a clear error message rather than crashing the assertion.mvn spotless:check -pl minions/async,webapppasses locally.Related issue(s)
See also #2058