|
1 | 1 | /*
|
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. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials are made available under the
|
5 | 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at
|
|
10 | 10 |
|
11 | 11 | package jakarta.xml.bind;
|
12 | 12 |
|
13 |
| -import java.io.IOException; |
14 |
| -import java.io.InputStream; |
15 | 13 | import java.lang.reflect.InvocationTargetException;
|
16 | 14 | import java.lang.reflect.Method;
|
17 | 15 | import java.net.URL;
|
18 | 16 | import java.security.AccessController;
|
19 | 17 | import java.security.PrivilegedAction;
|
20 | 18 | import java.security.PrivilegedActionException;
|
21 | 19 | import java.security.PrivilegedExceptionAction;
|
22 |
| -import java.util.Iterator; |
23 | 20 | import java.util.Map;
|
24 |
| -import java.util.Properties; |
| 21 | +import java.util.function.Predicate; |
25 | 22 | import java.util.logging.ConsoleHandler;
|
26 | 23 | import java.util.logging.Level;
|
27 | 24 | import java.util.logging.Logger;
|
| 25 | +import java.util.stream.Collectors; |
28 | 26 |
|
29 | 27 |
|
30 | 28 | /**
|
@@ -356,7 +354,14 @@ static JAXBContext find(Class<?>[] classes, Map<String, ?> properties) throws JA
|
356 | 354 | }
|
357 | 355 | }
|
358 | 356 | 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); |
360 | 365 | }
|
361 | 366 | }
|
362 | 367 |
|
|
0 commit comments