diff options
author | Jim Hahn <jrh3@att.com> | 2020-05-12 12:11:14 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-05-12 12:36:43 -0400 |
commit | 56564f91a91e496cac03ba7cae5a7d935140a574 (patch) | |
tree | 36c77a208f147d22db9b2ef673c8dda43bfe08de /models-interactions/model-impl/aai/src/main | |
parent | 6ee3629b07f2167c9c3253142ea8e4d17a4848d5 (diff) |
Fix race condition in AaiCqResponse
The JAXB unmarshaller used by AaiCqResponse is not thread safe. As a
result, if two responses are decoded at the same time, it will generate
exceptions.
Issue-ID: POLICY-2556
Change-Id: I5e81d5f3c39b9ba321c146dc6f4f73e558aaca3e
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-impl/aai/src/main')
-rw-r--r-- | models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java | 9 | ||||
-rw-r--r-- | models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java | 1 |
2 files changed, 5 insertions, 5 deletions
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java index 1e14e0704..1b18e439c 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.eclipse.persistence.jaxb.JAXBContextProperties; @@ -56,7 +55,6 @@ public class AaiCqResponse implements Serializable { private static final String VF_MODULE = "vf-module"; private static final Logger LOGGER = LoggerFactory.getLogger(AaiCqResponse.class); private static JAXBContext jaxbContext; - private static Unmarshaller unmarshaller; // JABX initial stuff static { @@ -76,7 +74,10 @@ public class AaiCqResponse implements Serializable { ModelVer.class }, properties); // @formatter:on - unmarshaller = jaxbContext.createUnmarshaller(); + + // verify that we can create an unmarshaller + jaxbContext.createUnmarshaller(); + } catch (JAXBException e) { LOGGER.error("Could not initialize JAXBContext", e); LOGGER.info("Problem initiatlizing JAXBContext", e); @@ -213,7 +214,7 @@ public class AaiCqResponse implements Serializable { private <T> T getAaiObject(StreamSource json, final Class<T> classOfResponse) { try { - return unmarshaller.unmarshal(json, classOfResponse).getValue(); + return jaxbContext.createUnmarshaller().unmarshal(json, classOfResponse).getValue(); } catch (JAXBException e) { LOGGER.error("JAXBCOntext error", e); return null; diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java index 24dcd8bbd..81aea9f98 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; - import org.json.JSONArray; import org.json.JSONObject; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; |