James Netherton created CAMEL-26496:
---------------------------------------
Summary: camel-keycloak: Remove the keycloak-core dependency to
avoid duplicate classes on the classpath
Key: CAMEL-26496
URL: https://issues.apache.org/jira/browse/CAMEL-26496
Project: Camel
Issue Type: Improvement
Components: camel-keycloak
Reporter: James Netherton
{{camel-keycloak}} declares both the Keycloak client libraries and
{{{}keycloak-core{}}}:
* {{keycloak-admin-client}} and {{{}keycloak-authz-client{}}}:
{{{}$\{keycloak-client-version{}}}} (26.0.12)
* {{{}keycloak-core{}}}: {{{}$\{keycloak-version{}}}} (26.8.1), which brings
in {{keycloak-common}}
The client libraries depend on {{{}keycloak-client-common-synced{}}}, which
contains copies of {{keycloak-core}} and {{keycloak-common}} classes under the
same {{org.keycloak.*}} package names. As a result, two versions of the same
classes end up on the classpath, and a dependency tree does not show this.
Since the versions were split in CAMEL-23664, the copies have also diverged.
Comparing the jars used by Camel 4.23.0:
||keycloak-client-common-synced 26.0.12 compared with||Shared
classes||Different bytes||
|keycloak-core 26.8.0|301|36|
|keycloak-common 26.8.0|127|16|
Only 3 of the 431 classes in {{keycloak-client-common-synced}} are unique to it.
Which copy gets loaded depends on classpath order, so behaviour can vary
between applications and runtimes. For example,
{{IdentityProviderRepresentation}} has {{organizationLinks}} in 26.8.0 but not
in 26.0.12. In Camel Quarkus, JVM mode resolves the 26.8.0 class and native
mode the 26.0.12 class, so a JSON payload with that field is rejected in native
mode:
{noformat}
UnrecognizedPropertyException: Unrecognized field "organizationLinks"
(class org.keycloak.representations.idm.IdentityProviderRepresentation), not
marked as ignorable
{noformat}
The dependency appears to be unnecessary. A bytecode scan of the
{{camel-keycloak}} 4.23.0 main classes found 61 referenced {{org.keycloak}}
classes: 34 in the client jars, 27 in {{{}keycloak-client-common-synced{}}},
and none only in {{keycloak-core}} or {{{}keycloak-common{}}}. All referenced
members of the {{keycloak-client-common-synced}} classes also exist there.
h3. Proposed change
* Remove {{keycloak-core}} from {{{}components/camel-keycloak/pom.xml{}}}.
* Remove the {{keycloak-version}} property from {{parent/pom.xml}} if nothing
else needs it.
* Keep the Keycloak test container version independent of the client library
version.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)