Bug579128 classloaderleak beanvalidation (#1449)
BUG579128: Classloader leak during unmarshal using BeanValidation
Signed-off-by: lananda <lalitha.ananda@oracle.com>
diff --git a/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/JAXBContext.java b/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/JAXBContext.java
index b5b5dc1..a771c4d 100644
--- a/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/JAXBContext.java
+++ b/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/JAXBContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -194,8 +194,8 @@ public boolean handleEvent(ValidationEvent event) {
private boolean initializedXMLInputFactory = false;
private JAXBMarshaller jsonSchemaMarshaller;
- private static volatile BeanValidationHelper beanValidationHelper;
- private static volatile Boolean beanValidationPresent;
+ private BeanValidationHelper beanValidationHelper;
+ private Boolean beanValidationPresent;
protected JAXBContext() {
super();
diff --git a/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/beanvalidation/ValidationXMLTestCase.java b/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/beanvalidation/ValidationXMLTestCase.java
index b2e7f26..6a4d149 100644
--- a/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/beanvalidation/ValidationXMLTestCase.java
+++ b/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/beanvalidation/ValidationXMLTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -139,21 +139,6 @@ public void testExternalConstraints() throws Exception {
public void setUp() throws Exception {
classLoader = new ValidationClassLoader(currentThread.getContextClassLoader());
currentThread.setContextClassLoader(classLoader);
- resetBeanValidation();
- }
-
- private void resetBeanValidation() throws Exception {
- Field beanValidationHelper = JAXBContext.class.getDeclaredField("beanValidationHelper");
- Field beanValidationPresent = JAXBContext.class.getDeclaredField("beanValidationPresent");
-
- beanValidationHelper.setAccessible(true);
- beanValidationPresent.setAccessible(true);
-
- beanValidationHelper.set(JAXBContext.class, null);
- beanValidationPresent.set(JAXBContext.class, null);
-
- beanValidationHelper.setAccessible(false);
- beanValidationPresent.setAccessible(false);
}
@Override