Skip to content

Commit accd3d7

Browse files
authored
Bug579128 classloaderleak beanvalidation (#1449)
BUG579128: Classloader leak during unmarshal using BeanValidation Signed-off-by: lananda <[email protected]>
1 parent 72cf9f8 commit accd3d7

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/JAXBContext.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -194,8 +194,8 @@ public boolean handleEvent(ValidationEvent event) {
194194
private boolean initializedXMLInputFactory = false;
195195
private JAXBMarshaller jsonSchemaMarshaller;
196196

197-
private static volatile BeanValidationHelper beanValidationHelper;
198-
private static volatile Boolean beanValidationPresent;
197+
private BeanValidationHelper beanValidationHelper;
198+
private Boolean beanValidationPresent;
199199

200200
protected JAXBContext() {
201201
super();

moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/beanvalidation/ValidationXMLTestCase.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -139,21 +139,6 @@ public void testExternalConstraints() throws Exception {
139139
public void setUp() throws Exception {
140140
classLoader = new ValidationClassLoader(currentThread.getContextClassLoader());
141141
currentThread.setContextClassLoader(classLoader);
142-
resetBeanValidation();
143-
}
144-
145-
private void resetBeanValidation() throws Exception {
146-
Field beanValidationHelper = JAXBContext.class.getDeclaredField("beanValidationHelper");
147-
Field beanValidationPresent = JAXBContext.class.getDeclaredField("beanValidationPresent");
148-
149-
beanValidationHelper.setAccessible(true);
150-
beanValidationPresent.setAccessible(true);
151-
152-
beanValidationHelper.set(JAXBContext.class, null);
153-
beanValidationPresent.set(JAXBContext.class, null);
154-
155-
beanValidationHelper.setAccessible(false);
156-
beanValidationPresent.setAccessible(false);
157142
}
158143

159144
@Override

0 commit comments

Comments
 (0)