This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 2b88e84408 Simplifying ImportHandler to not test class presence with
getResource
2b88e84408 is described below
commit 2b88e84408f04cec34e0b8458711bcc6ad8b7517
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Wed Aug 24 15:39:16 2022 +0200
Simplifying ImportHandler to not test class presence with getResource
(no more perf boost from it on modern JRE)
---
java/javax/el/ImportHandler.java | 50 ----------------------------------------
webapps/docs/changelog.xml | 6 +++++
2 files changed, 6 insertions(+), 50 deletions(-)
diff --git a/java/javax/el/ImportHandler.java b/java/javax/el/ImportHandler.java
index 9cc5daa68a..ac19a16737 100644
--- a/java/javax/el/ImportHandler.java
+++ b/java/javax/el/ImportHandler.java
@@ -19,8 +19,6 @@ package javax.el;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -33,8 +31,6 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ImportHandler {
- private static final boolean IS_SECURITY_ENABLED =
(System.getSecurityManager() != null);
-
private static final Map<String,Set<String>> standardPackages = new
HashMap<>();
static {
@@ -452,31 +448,6 @@ public class ImportHandler {
private Class<?> findClass(String name, boolean throwException) {
Class<?> clazz;
ClassLoader cl = Util.getContextClassLoader();
- String path = name.replace('.', '/') + ".class";
- try {
- /* Given that findClass() has to be called for every imported
- * package and that getResource() is a lot faster then loadClass()
- * for resources that don't exist, the overhead of the
getResource()
- * for the case where the class does exist is a lot less than the
- * overhead we save by not calling loadClass().
- */
- if (IS_SECURITY_ENABLED) {
- // Webapps don't have read permission for JAVA_HOME (and
- // possibly other sources of classes). Only need to know if the
- // class exists at this point. Class loading occurs with
- // standard SecurityManager policy next.
- if (!AccessController.doPrivileged(new
PrivilegedResourceExists(cl, path)).booleanValue()) {
- return null;
- }
- } else {
- if (cl.getResource(path) == null) {
- return null;
- }
- }
- } catch (ClassCircularityError cce) {
- // May happen under a security manager. Ignore it and try loading
- // the class normally.
- }
try {
clazz = cl.loadClass(name);
} catch (ClassNotFoundException e) {
@@ -507,25 +478,4 @@ public class ImportHandler {
*/
private static class NotFound {
}
-
-
- private static class PrivilegedResourceExists implements
PrivilegedAction<Boolean> {
-
- private final ClassLoader cl;
- private final String name;
-
- public PrivilegedResourceExists(ClassLoader cl, String name) {
- this.cl = cl;
- this.name = name;
- }
-
- @Override
- public Boolean run() {
- if (cl.getResource(name) == null) {
- return Boolean.FALSE;
- } else {
- return Boolean.TRUE;
- }
- }
- }
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a4620c310e..5e689acdb4 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -170,6 +170,12 @@
so that larger values are correctly parsed to <code>BigInteger</code>
and <code>BigDecimal</code> respectively. (markt)
</fix>
+ <fix>
+ Improve the performance of the <code>ImportHandler</code> in the
+ Expression Language implementation. This removes a previous
optimisation
+ that is now detrimental rather than helpful. Pull request <pr>547</pr>
+ provided by rmannibucau. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Cluster">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]