This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 1a36206abb Fix BZ 68721 - avoid duplicate class definition
1a36206abb is described below
commit 1a36206abba24a16d779967ec6f8c3c61c634c83
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Mar 7 13:51:20 2024 -0500
Fix BZ 68721 - avoid duplicate class definition
Triggered if the transformation of a class also triggers loading of the
same class.
---
java/org/apache/catalina/loader/WebappClassLoaderBase.java | 11 +++++++++++
webapps/docs/changelog.xml | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index b2ca9de81b..90e8a33d7c 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -2163,6 +2163,17 @@ public abstract class WebappClassLoaderBase extends
URLClassLoader
} catch (UnsupportedClassVersionError ucve) {
throw new UnsupportedClassVersionError(
ucve.getLocalizedMessage() + " " +
sm.getString("webappClassLoader.wrongVersion", name));
+ } catch (LinkageError e) {
+ // May be caused by the transformation also triggering loading
of the class - BZ 68721
+ try {
+ // Try and load the already defined class
+ clazz = findLoadedClass0(name);
+ } catch (Throwable t) {
+ // Not BZ 68721
+ ExceptionUtils.handleThrowable(t);
+ // Re-throw the original exception
+ throw e;
+ }
}
entry.loadedClass = clazz;
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 811e04a909..2b7c44c50f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -144,6 +144,12 @@
<code>Context</code> to control the bahavior, defaulting to
<code>true</code>. (remm)
</fix>
+ <fix>
+ <bug>68721</bug>: Workaround a possible cause of duplicate class
+ definitions when using <code>ClassFileTransformer</code>s and the
+ transformation of a class also triggers the loading of the same class.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]