X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fmain%2Fcomm%2FPdpStatusMessageHandler.java;h=4d1421143358bdaf7f58c18f8fbb0a22b67ff4cf;hb=5a9b9d9513a021c00415f9bee0698ea9c497c238;hp=070261dbdd69f0055b040834ec629a5f0addb5a3;hpb=6763c4b787593fa0a11668971ba2cb5cc87ad4c5;p=policy%2Fpap.git diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java index 070261db..4d142114 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021,2023 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ @@ -34,7 +34,6 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import org.apache.commons.lang3.builder.EqualsBuilder; -import org.eclipse.persistence.exceptions.EclipseLinkException; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; @@ -131,7 +130,7 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator { } catch (final PolicyPapException exp) { LOGGER.error("Operation Failed", exp); } catch (final Exception exp) { - if (isDuplicateKeyException(exp)) { + if (isDuplicateKeyException(exp, Exception.class)) { /* * this is to be expected, if multiple PAPs are processing the same * heartbeat at a time, thus we log the exception at a trace level @@ -151,17 +150,17 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator { * Determines if the exception indicates a duplicate key. * * @param thrown exception to check + * @param exceptionClazz the class to check against * @return {@code true} if the exception occurred due to a duplicate key */ - protected static boolean isDuplicateKeyException(Throwable thrown) { + protected static boolean isDuplicateKeyException(Throwable thrown, Class exceptionClazz) { while (thrown != null) { if (thrown instanceof SQLIntegrityConstraintViolationException) { return true; } - if (thrown instanceof EclipseLinkException) { - EclipseLinkException ele = (EclipseLinkException) thrown; - if (isDuplicateKeyException(ele.getInternalException())) { + if (exceptionClazz.isInstance(thrown)) { + if (isDuplicateKeyException(thrown.getCause(), exceptionClazz)) { return true; } }