From 9d429400d4574bdbc8219b089c9a8dd7d297c0f2 Mon Sep 17 00:00:00 2001 From: Thomas Darimont Date: Thu, 11 Jan 2024 11:54:44 +0100 Subject: [PATCH] Avoid calling primitive wrapper constructors in server-spi-private (#24163) Signed-off-by: Thomas Darimont --- .../org/keycloak/validate/validators/DoubleValidator.java | 2 +- .../org/keycloak/validate/validators/IntegerValidator.java | 2 +- .../src/main/java/org/keycloak/validate/ValidatorConfig.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server-spi-private/src/main/java/org/keycloak/validate/validators/DoubleValidator.java b/server-spi-private/src/main/java/org/keycloak/validate/validators/DoubleValidator.java index d8b3f063bb..200076d2a7 100644 --- a/server-spi-private/src/main/java/org/keycloak/validate/validators/DoubleValidator.java +++ b/server-spi-private/src/main/java/org/keycloak/validate/validators/DoubleValidator.java @@ -49,7 +49,7 @@ public class DoubleValidator extends AbstractNumberValidator implements Configur if (value instanceof Number) { return (Number) value; } - return new Double(value.toString()); + return Double.valueOf(value.toString()); } @Override diff --git a/server-spi-private/src/main/java/org/keycloak/validate/validators/IntegerValidator.java b/server-spi-private/src/main/java/org/keycloak/validate/validators/IntegerValidator.java index 3e9a4d1e88..e34113101c 100644 --- a/server-spi-private/src/main/java/org/keycloak/validate/validators/IntegerValidator.java +++ b/server-spi-private/src/main/java/org/keycloak/validate/validators/IntegerValidator.java @@ -44,7 +44,7 @@ public class IntegerValidator extends AbstractNumberValidator implements Configu if (value instanceof Integer || value instanceof Long) { return (Number) value; } - return new Long(value.toString()); + return Long.valueOf(value.toString()); } @Override diff --git a/server-spi/src/main/java/org/keycloak/validate/ValidatorConfig.java b/server-spi/src/main/java/org/keycloak/validate/ValidatorConfig.java index e9901a1824..86645199d1 100644 --- a/server-spi/src/main/java/org/keycloak/validate/ValidatorConfig.java +++ b/server-spi/src/main/java/org/keycloak/validate/ValidatorConfig.java @@ -108,7 +108,7 @@ public class ValidatorConfig { return ((Number) value).intValue(); } else if (value instanceof String) { try { - return new Integer((String) value); + return Integer.valueOf((String) value); } catch (NumberFormatException e) { return null; } @@ -128,7 +128,7 @@ public class ValidatorConfig { return ((Number) value).longValue(); } else if (value instanceof String) { try { - return new Long((String) value); + return Long.valueOf((String) value); } catch (NumberFormatException e) { return null; }