This is an automated email from the ASF dual-hosted git repository.

markt-asf 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 64457c08d3 Remove unnecessary intern() calls.
64457c08d3 is described below

commit 64457c08d35b25ef5613c0a9961c8cb3b9ce5635
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Jul 9 11:29:35 2026 +0100

    Remove unnecessary intern() calls.
    
    Values and body text are less likely to be duplicated and there are
    better ways to avoid String duplication if it is really an issue.
---
 java/org/apache/tomcat/util/digester/CallMethodRule.java | 2 +-
 java/org/apache/tomcat/util/digester/Digester.java       | 5 ++---
 webapps/docs/changelog.xml                               | 4 ++++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java 
b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index e80c02fb26..9199ff415d 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -229,7 +229,7 @@ public class CallMethodRule extends Rule {
     public void body(String namespace, String name, String bodyText) throws 
Exception {
 
         if (paramCount == 0) {
-            this.bodyText = bodyText.trim().intern();
+            this.bodyText = bodyText.trim();
         }
 
     }
diff --git a/java/org/apache/tomcat/util/digester/Digester.java 
b/java/org/apache/tomcat/util/digester/Digester.java
index 4155363bf1..bff710ae52 100644
--- a/java/org/apache/tomcat/util/digester/Digester.java
+++ b/java/org/apache/tomcat/util/digester/Digester.java
@@ -1088,7 +1088,7 @@ public class Digester extends DefaultHandler2 {
         // Fire "body" events for all relevant rules
         List<Rule> rules = matches.pop();
         if ((rules != null) && (!rules.isEmpty())) {
-            String bodyText = this.bodyText.toString().intern();
+            String bodyText = this.bodyText.toString();
             for (Rule rule : rules) {
                 try {
                     if (debug) {
@@ -2129,8 +2129,7 @@ public class Digester extends DefaultHandler2 {
         for (int i = 0; i < nAttributes; ++i) {
             String value = newAttrs.getValue(i);
             try {
-                newAttrs.setValue(i,
-                        IntrospectionUtils.replaceProperties(value, null, 
source, getClassLoader()).intern());
+                newAttrs.setValue(i, 
IntrospectionUtils.replaceProperties(value, null, source, getClassLoader()));
             } catch (Exception e) {
                 log.warn(sm.getString("digester.failedToUpdateAttributes", 
newAttrs.getLocalName(i), value), e);
             }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d82fd1d005..b726f6331f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -235,6 +235,10 @@
         Ensure that a <code>login-config</code> conflict when merging web.xml
         fragments triggers a deployment failure. (markt)
       </fix>
+      <scode>
+        Remove unnecessary calls to <code>String.intern()</code> in the parsing
+        of configuration files. (markt)
+      </scode>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to