Skip to content

Commit 4f2ab0e

Browse files
committed
Make sure providers get only properties they are required to understand
Signed-off-by: Lukas Jungmann <[email protected]>
1 parent 66b10a6 commit 4f2ab0e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

api/src/main/java/jakarta/xml/bind/ContextFinder.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2023 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 Distribution License v. 1.0, which is available at
@@ -10,21 +10,19 @@
1010

1111
package jakarta.xml.bind;
1212

13-
import java.io.IOException;
14-
import java.io.InputStream;
1513
import java.lang.reflect.InvocationTargetException;
1614
import java.lang.reflect.Method;
1715
import java.net.URL;
1816
import java.security.AccessController;
1917
import java.security.PrivilegedAction;
2018
import java.security.PrivilegedActionException;
2119
import java.security.PrivilegedExceptionAction;
22-
import java.util.Iterator;
2320
import java.util.Map;
24-
import java.util.Properties;
21+
import java.util.function.Predicate;
2522
import java.util.logging.ConsoleHandler;
2623
import java.util.logging.Level;
2724
import java.util.logging.Logger;
25+
import java.util.stream.Collectors;
2826

2927

3028
/**
@@ -356,7 +354,14 @@ static JAXBContext find(Class<?>[] classes, Map<String, ?> properties) throws JA
356354
}
357355
}
358356
if (factoryClassName != null) {
359-
return newInstance(classes, properties, factoryClassName);
357+
//Providers are not required to understand JAXB_CONTEXT_FACTORY property
358+
//and they must throw a JAXBException if they see it, so we need to remove it
359+
//from properties passed to them
360+
Map<String, ?> props = properties.entrySet()
361+
.stream()
362+
.filter(Predicate.not(e -> JAXBContext.JAXB_CONTEXT_FACTORY.equals(e.getKey())))
363+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
364+
return newInstance(classes, props, factoryClassName);
360365
}
361366
}
362367

0 commit comments

Comments
 (0)