This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit bdc927267b0e050f038302e948c6d72bce3436a1
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Jan 27 06:06:48 2026 +0000

    (chores): modernize instanceof checks in camel-keycloak
---
 .../camel/component/keycloak/KeycloakProducer.java | 32 +++++++++++-----------
 .../security/KeycloakTokenIntrospector.java        | 14 +++++-----
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git 
a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
 
b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
index ae5b2516c9cf..0e40dc1102a1 100644
--- 
a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
+++ 
b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
@@ -1307,9 +1307,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof IdentityProviderRepresentation) {
+            if (payload instanceof IdentityProviderRepresentation 
idpRepresentation) {
                 Response response
-                        = 
keycloakClient.realm(realmName).identityProviders().create((IdentityProviderRepresentation)
 payload);
+                        = 
keycloakClient.realm(realmName).identityProviders().create(idpRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody(response);
             }
@@ -1365,9 +1365,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof IdentityProviderRepresentation) {
+            if (payload instanceof IdentityProviderRepresentation 
idpRepresentation) {
                 
keycloakClient.realm(realmName).identityProviders().get(idpAlias)
-                        .update((IdentityProviderRepresentation) payload);
+                        .update(idpRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody("Identity provider updated successfully");
             }
@@ -1402,9 +1402,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ResourceRepresentation) {
+            if (payload instanceof ResourceRepresentation 
resourceRepresentation) {
                 Response response = 
keycloakClient.realm(realmName).clients().get(clientUuid).authorization().resources()
-                        .create((ResourceRepresentation) payload);
+                        .create(resourceRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody(response);
             }
@@ -1475,9 +1475,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ResourceRepresentation) {
+            if (payload instanceof ResourceRepresentation 
resourceRepresentation) {
                 
keycloakClient.realm(realmName).clients().get(clientUuid).authorization().resources().resource(resourceId)
-                        .update((ResourceRepresentation) payload);
+                        .update(resourceRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody("Resource updated successfully");
             }
@@ -1516,9 +1516,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof PolicyRepresentation) {
+            if (payload instanceof PolicyRepresentation policyRepresentation) {
                 Response response = 
keycloakClient.realm(realmName).clients().get(clientUuid).authorization().policies()
-                        .create((PolicyRepresentation) payload);
+                        .create(policyRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody(response);
             }
@@ -1589,9 +1589,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof PolicyRepresentation) {
+            if (payload instanceof PolicyRepresentation policyRepresentation) {
                 
keycloakClient.realm(realmName).clients().get(clientUuid).authorization().policies().policy(policyId)
-                        .update((PolicyRepresentation) payload);
+                        .update(policyRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody("Policy updated successfully");
             }
@@ -1630,9 +1630,9 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ResourcePermissionRepresentation) {
+            if (payload instanceof ResourcePermissionRepresentation 
permissionRepresentation) {
                 Response response = 
keycloakClient.realm(realmName).clients().get(clientUuid).authorization().permissions()
-                        .resource().create((ResourcePermissionRepresentation) 
payload);
+                        .resource().create(permissionRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody(response);
             }
@@ -1705,10 +1705,10 @@ public class KeycloakProducer extends DefaultProducer {
 
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof PolicyRepresentation) {
+            if (payload instanceof PolicyRepresentation policyRepresentation) {
                 // Use policy endpoint for permissions
                 
keycloakClient.realm(realmName).clients().get(clientUuid).authorization().policies().policy(permissionId)
-                        .update((PolicyRepresentation) payload);
+                        .update(policyRepresentation);
                 Message message = getMessageForResponse(exchange);
                 message.setBody("Permission updated successfully");
             }
diff --git 
a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java
 
b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java
index 25f473c1fac2..61f6f1d62b4b 100644
--- 
a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java
+++ 
b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java
@@ -160,8 +160,8 @@ public class KeycloakTokenIntrospector {
 
             return result;
         } catch (Exception e) {
-            if (e instanceof IOException) {
-                throw (IOException) e;
+            if (e instanceof IOException ioException) {
+                throw ioException;
             }
             throw new IOException("Failed to introspect token", e);
         }
@@ -249,7 +249,7 @@ public class KeycloakTokenIntrospector {
          */
         public boolean isActive() {
             Object active = claims.get("active");
-            return active instanceof Boolean && (Boolean) active;
+            return active instanceof Boolean b && b;
         }
 
         /**
@@ -304,8 +304,8 @@ public class KeycloakTokenIntrospector {
          */
         public Long getExpiration() {
             Object exp = claims.get("exp");
-            if (exp instanceof Number) {
-                return ((Number) exp).longValue();
+            if (exp instanceof Number number) {
+                return number.longValue();
             }
             return null;
         }
@@ -317,8 +317,8 @@ public class KeycloakTokenIntrospector {
          */
         public Long getIssuedAt() {
             Object iat = claims.get("iat");
-            if (iat instanceof Number) {
-                return ((Number) iat).longValue();
+            if (iat instanceof Number number) {
+                return number.longValue();
             }
             return null;
         }

Reply via email to