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 56c57a24d8de6e2bbe8971995cca151c159a2778 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Fri Jan 6 10:20:12 2023 +0100 (chores) camel-hyperledger-aries: avoid risky unboxing --- .../CredentialDefinitionsServiceHandler.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/CredentialDefinitionsServiceHandler.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/CredentialDefinitionsServiceHandler.java index 0aeee9d7ab4..f1f69bc0571 100644 --- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/CredentialDefinitionsServiceHandler.java +++ b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/CredentialDefinitionsServiceHandler.java @@ -83,17 +83,8 @@ public class CredentialDefinitionsServiceHandler extends AbstractServiceHandler } AssertState.notNull(schemaVersion, "Cannot obtain schemaVersion"); - Boolean autoSchema = null; Object auxValue = spec.get("autoSchema"); - if (auxValue instanceof Boolean) { - autoSchema = Boolean.valueOf((Boolean) auxValue); - } - if (auxValue instanceof String) { - autoSchema = Boolean.valueOf((String) auxValue); - } - if (autoSchema == null) { - autoSchema = endpoint.getConfiguration().isAutoSchema(); - } + boolean autoSchema = isAutoSchema(auxValue); // Search existing schemas DID publicDid = createClient().walletDidPublic().get(); @@ -141,4 +132,15 @@ public class CredentialDefinitionsServiceHandler extends AbstractServiceHandler throw new UnsupportedServiceException(service); } } + + private boolean isAutoSchema(Object auxValue) { + if (auxValue instanceof Boolean) { + return Boolean.valueOf((Boolean) auxValue); + } + if (auxValue instanceof String) { + return Boolean.valueOf((String) auxValue); + } + + return endpoint.getConfiguration().isAutoSchema(); + } }
