Skip to content

Handle the STRICT host name verifier explicitly (CodeQL java/missing-case-in-switch)#244

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:features/codeql-missing-case-switch
Open

Handle the STRICT host name verifier explicitly (CodeQL java/missing-case-in-switch)#244
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:features/codeql-missing-case-switch

Conversation

@vharseko

@vharseko vharseko commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Resolves the java/missing-case-in-switch alert in AsyncHttpClientProvider
(the switch had no case for HostnameVerifier.STRICT).

The switch pre-initialised the verifier and only overrode it for ALLOW_ALL:

HostnameVerifier verifier = new DefaultHostnameVerifier();
switch (options.get(OPTION_HOSTNAME_VERIFIER)) {
case ALLOW_ALL:
    verifier = NoopHostnameVerifier.INSTANCE;
    break;
}

STRICT therefore fell through and kept the default DefaultHostnameVerifier
(the correct behaviour), but the switch covered only one of the two enum values.

Fix

Add a default branch that assigns DefaultHostnameVerifier, matching the shape
already used by the sibling SyncHttpClientProvider:

final HostnameVerifier verifier;
switch (options.get(OPTION_HOSTNAME_VERIFIER)) {
case ALLOW_ALL:
    verifier = NoopHostnameVerifier.INSTANCE;
    break;
default:
    verifier = new DefaultHostnameVerifier();
    break;
}

Behaviour is unchanged (STRICT still maps to DefaultHostnameVerifier); the
switch now covers every value and the two providers are consistent.

Testing

mvn -o -pl commons/http-framework/client-apache-async compile — BUILD SUCCESS.

…case-in-switch)

AsyncHttpClientProvider switched on the HostnameVerifier option but only had a
case for ALLOW_ALL, relying on a pre-initialised DefaultHostnameVerifier to cover
STRICT. Give the switch a default branch that assigns the strict verifier, the
same shape already used by SyncHttpClientProvider.

Behaviour is unchanged - STRICT still maps to DefaultHostnameVerifier - but the
switch now covers every enum value and the two client providers are consistent.
@vharseko vharseko requested a review from maximthomas July 8, 2026 14:46
@vharseko vharseko added codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change labels Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants