Improve performance and maintainability of CIMD client policy code#1480
Closed
Copilot wants to merge 2 commits intoISSUE-45284from
Closed
Improve performance and maintainability of CIMD client policy code#1480Copilot wants to merge 2 commits intoISSUE-45284from
Copilot wants to merge 2 commits intoISSUE-45284from
Conversation
Performance: - Parse URI once in ClientIdUriSchemeCondition.applyPolicy() instead of twice - Compute trustedDomains list once and pass to verifyUri() instead of recomputing per call - Single-pass Cache-Control header parsing (was 6 stream passes) - Single-pass HTTP header lookup for Cache-Control (was 2 array scans) - Avoid duplicate ClientMetadataCacheControl creation in fetchClientMetadata() Maintainability: - Fix unused paContext variable (use it instead of re-casting context) - Fix swapped comments in process() (CREATE said "Update", UPDATE said "Create") - Fix wrong HTTP status in Javadoc (307 → 304 Not Modified) - Fix misleading "regex" in config descriptions (actually uses wildcard matching) - Fix typo "mandagory" → "mandatory" - Extract verifyUriProperty/verifyUriPropertyIfPresent helpers to reduce boilerplate - Remove unused NameValuePair import Co-authored-by: tnorimat <25092005+tnorimat@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review performance and maintainability improvements for ISSUE-45284
Improve performance and maintainability of CIMD client policy code
Feb 28, 2026
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.
Review of the ISSUE-45284 branch identifying performance bottlenecks and maintainability issues in the CIMD (Client ID Metadata Document) client policy code.
Description
Performance
ClientIdUriSchemeCondition.applyPolicy()—clientIdwas parsed toURIseparately in bothisUriSchemeMatched()andisTrustedDomainMatched(). Now parsed once.convertContentFilledList()inverifyUri()— Called up to 8+ times perverifyClientMetadata()invocation on the same config input. Now computed once and passed as parameter.ClientMetadataCacheControlconstructor streamed the directive list 6 times. Replaced with one for-loop.headers[]. Replaced with one for-loop + early break.ClientMetadataCacheControlconstruction —fetchClientMetadata()built one, thenOIDCClientRepresentationWithCacheControlbuilt another from the raw string. Now accepts the already-parsed object.Maintainability
paContextassigned thencontextre-cast on next line.CREATEblock said "Update",UPDATEblock said "Create".307→304Not Modified.checkTrustedDomain()uses*.wildcard matching.verifyUriProperty/verifyUriPropertyIfPresenthelpers — Replaces 8 repetitive lambda blocks inverifyClientMetadata():NameValuePairimport.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
repo.gradle.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/keycloak/keycloak org.codehaus.plexus.classworlds.launcher.Launcher compile -pl services -am -DskipTests -Dformat.skip=true -Denforcer.skip=true -Dcheckstyle.skip=true -Dimpsort.skip=true -q(dns block)repository.jboss.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/keycloak/keycloak org.codehaus.plexus.classworlds.launcher.Launcher compile -pl services -am -DskipTests -Dformat.skip=true -Denforcer.skip=true -Dcheckstyle.skip=true -Dimpsort.skip=true -q(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.