This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 3b8f277a7f Set context CL before calling XMLInputFactory.newFactory
3b8f277a7f is described below
commit 3b8f277a7ffc1193ed6c6d4fff85db6dc7327e39
Author: remm <[email protected]>
AuthorDate: Mon Mar 25 10:45:28 2024 +0100
Set context CL before calling XMLInputFactory.newFactory
Passing the CL to XMLInputFactory.newFactory does not work because it
needs an id (basically the concrete class to load).
Try the context CL instead.
The class is preloaded for previous Tomcat versions so it shouldn't be a
security manager issue.
---
java/org/apache/jasper/compiler/EncodingDetector.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/jasper/compiler/EncodingDetector.java
b/java/org/apache/jasper/compiler/EncodingDetector.java
index cf3b623104..fb7795ca16 100644
--- a/java/org/apache/jasper/compiler/EncodingDetector.java
+++ b/java/org/apache/jasper/compiler/EncodingDetector.java
@@ -35,8 +35,15 @@ class EncodingDetector {
private static final XMLInputFactory XML_INPUT_FACTORY;
static {
- XML_INPUT_FACTORY =
XMLInputFactory.newFactory(XMLInputFactory.class.getName(),
- EncodingDetector.class.getClassLoader());
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ try {
+
Thread.currentThread().setContextClassLoader(EncodingDetector.class.getClassLoader());
+ XML_INPUT_FACTORY = XMLInputFactory.newFactory();
+ } finally {
+ if (oldCl != null) {
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+ }
}
private final String encoding;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]