You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/11/27 18:29:27 UTC
(tomcat) branch 8.5.x updated (d28ddf4d55 -> 8df7a3a95b)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from d28ddf4d55 Fix warnings / widen background process / lifecycle fix
new 340fd82368 Test case for BZ 68119
new 8c1a015730 Clean-up prior to fixing BZ 68119
new 6107ed1d33 Add comment on why >= rather than == is used
new 8df7a3a95b Fix BZ 68119 - Refactor for improved performance during type conversion
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
java/javax/el/CompositeELResolver.java | 83 +++++++++++++++++-----
.../TestCompositeELResolverPerformance.java} | 35 ++++-----
webapps/docs/changelog.xml | 8 +++
3 files changed, 90 insertions(+), 36 deletions(-)
copy test/javax/{servlet/jsp/el/TestScopedAttributeELResolverPerformance.java => el/TestCompositeELResolverPerformance.java} (51%)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/04: Test case for BZ 68119
Posted by ma...@apache.org.
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
commit 340fd8236864e361e98e85cb686f3becee10272e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 27 13:34:48 2023 +0000
Test case for BZ 68119
https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
---
.../el/TestCompositeELResolverPerformance.java | 48 ++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/test/javax/el/TestCompositeELResolverPerformance.java b/test/javax/el/TestCompositeELResolverPerformance.java
new file mode 100644
index 0000000000..b31907cab5
--- /dev/null
+++ b/test/javax/el/TestCompositeELResolverPerformance.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.el;
+
+import org.junit.Test;
+
+public class TestCompositeELResolverPerformance {
+
+ /*
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
+ */
+ @Test
+ public void testConvertToType() throws Exception {
+ ELManager manager = new ELManager();
+ ELContext context = manager.getELContext();
+ ELResolver resolver = context.getELResolver();
+
+ // Warm-up
+ doConversion(context, resolver);
+
+ long start = System.nanoTime();
+ doConversion(context, resolver);
+ long duration = System.nanoTime() - start;
+
+ System.out.println("convertToType performance test complete in " + duration + "ns");
+ }
+
+
+ private void doConversion(ELContext context, ELResolver resolver) {
+ for (int i = 0; i < 10000000; i++) {
+ resolver.convertToType(context, "This is a String", String.class);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/04: Clean-up prior to fixing BZ 68119
Posted by ma...@apache.org.
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
commit 8c1a0157307f81c6399b94ba5a2dd9a542547240
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 27 13:43:00 2023 +0000
Clean-up prior to fixing BZ 68119
---
java/javax/el/CompositeELResolver.java | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/java/javax/el/CompositeELResolver.java b/java/javax/el/CompositeELResolver.java
index bed5375929..dade342c72 100644
--- a/java/javax/el/CompositeELResolver.java
+++ b/java/javax/el/CompositeELResolver.java
@@ -34,32 +34,32 @@ public class CompositeELResolver extends ELResolver {
SCOPED_ATTRIBUTE_EL_RESOLVER = clazz;
}
- private int size;
+ private int resolversSize;
private ELResolver[] resolvers;
public CompositeELResolver() {
- this.size = 0;
- this.resolvers = new ELResolver[8];
+ resolversSize = 0;
+ resolvers = new ELResolver[8];
}
public void add(ELResolver elResolver) {
Objects.requireNonNull(elResolver);
- if (this.size >= this.resolvers.length) {
- ELResolver[] nr = new ELResolver[this.size * 2];
- System.arraycopy(this.resolvers, 0, nr, 0, this.size);
- this.resolvers = nr;
+ if (resolversSize >= resolvers.length) {
+ ELResolver[] nr = new ELResolver[resolversSize * 2];
+ System.arraycopy(resolvers, 0, nr, 0, resolversSize);
+ resolvers = nr;
}
- this.resolvers[this.size++] = elResolver;
+ resolvers[resolversSize++] = elResolver;
}
@Override
public Object getValue(ELContext context, Object base, Object property) {
context.setPropertyResolved(false);
- int sz = this.size;
+ int sz = resolversSize;
for (int i = 0; i < sz; i++) {
- Object result = this.resolvers[i].getValue(context, base, property);
+ Object result = resolvers[i].getValue(context, base, property);
if (context.isPropertyResolved()) {
return result;
}
@@ -70,7 +70,7 @@ public class CompositeELResolver extends ELResolver {
@Override
public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) {
context.setPropertyResolved(false);
- int sz = this.size;
+ int sz = this.resolversSize;
for (int i = 0; i < sz; i++) {
Object obj = this.resolvers[i].invoke(context, base, method, paramTypes, params);
if (context.isPropertyResolved()) {
@@ -83,7 +83,7 @@ public class CompositeELResolver extends ELResolver {
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
context.setPropertyResolved(false);
- int sz = this.size;
+ int sz = this.resolversSize;
for (int i = 0; i < sz; i++) {
Class<?> type = this.resolvers[i].getType(context, base, property);
if (context.isPropertyResolved()) {
@@ -106,7 +106,7 @@ public class CompositeELResolver extends ELResolver {
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
context.setPropertyResolved(false);
- int sz = this.size;
+ int sz = this.resolversSize;
for (int i = 0; i < sz; i++) {
this.resolvers[i].setValue(context, base, property, value);
if (context.isPropertyResolved()) {
@@ -118,7 +118,7 @@ public class CompositeELResolver extends ELResolver {
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
context.setPropertyResolved(false);
- int sz = this.size;
+ int sz = this.resolversSize;
for (int i = 0; i < sz; i++) {
boolean readOnly = this.resolvers[i].isReadOnly(context, base, property);
if (context.isPropertyResolved()) {
@@ -130,13 +130,13 @@ public class CompositeELResolver extends ELResolver {
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
- return new FeatureIterator(context, base, this.resolvers, this.size);
+ return new FeatureIterator(context, base, this.resolvers, this.resolversSize);
}
@Override
public Class<?> getCommonPropertyType(ELContext context, Object base) {
Class<?> commonType = null;
- int sz = this.size;
+ int sz = this.resolversSize;
for (int i = 0; i < sz; i++) {
Class<?> type = this.resolvers[i].getCommonPropertyType(context, base);
if (type != null && (commonType == null || commonType.isAssignableFrom(type))) {
@@ -149,7 +149,7 @@ public class CompositeELResolver extends ELResolver {
@Override
public Object convertToType(ELContext context, Object obj, Class<?> type) {
context.setPropertyResolved(false);
- int sz = this.size;
+ int sz = this.resolversSize;
for (int i = 0; i < sz; i++) {
Object result = this.resolvers[i].convertToType(context, obj, type);
if (context.isPropertyResolved()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) 04/04: Fix BZ 68119 - Refactor for improved performance during type conversion
Posted by Mark Thomas <ma...@apache.org>.
On 27/11/2023 19:38, Rémy Maucherat wrote:
> On Mon, Nov 27, 2023 at 7:29 PM <ma...@apache.org> wrote:
>>
>> 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
>>
>> commit 8df7a3a95babb12fc38b8efa7eb938877ef38485
>> Author: Mark Thomas <ma...@apache.org>
>> AuthorDate: Mon Nov 27 14:01:49 2023 +0000
>>
>> Fix BZ 68119 - Refactor for improved performance during type conversion
>>
>> https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
>> ---
>> java/javax/el/CompositeELResolver.java | 47 +++++++++++++++++++++++++++++++---
>> webapps/docs/changelog.xml | 8 ++++++
>> 2 files changed, 52 insertions(+), 3 deletions(-)
>>
>> diff --git a/java/javax/el/CompositeELResolver.java b/java/javax/el/CompositeELResolver.java
>> index ee14d6bcc3..2280f9a805 100644
>> --- a/java/javax/el/CompositeELResolver.java
>> +++ b/java/javax/el/CompositeELResolver.java
>> @@ -17,13 +17,16 @@
>> package javax.el;
>>
>> import java.beans.FeatureDescriptor;
>> +import java.util.HashSet;
>> import java.util.Iterator;
>> import java.util.NoSuchElementException;
>> import java.util.Objects;
>> +import java.util.Set;
>>
>> public class CompositeELResolver extends ELResolver {
>>
>> private static final Class<?> SCOPED_ATTRIBUTE_EL_RESOLVER;
>> + private static final Set<String> KNOWN_NON_TYPE_CONVERTING_RESOLVERS = new HashSet<>();
>> static {
>> Class<?> clazz = null;
>> try {
>> @@ -32,15 +35,39 @@ public class CompositeELResolver extends ELResolver {
>> // Ignore. This is expected if using the EL stand-alone
>> }
>> SCOPED_ATTRIBUTE_EL_RESOLVER = clazz;
>> +
>> + // EL API Resolvers
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ArrayELResolver.class.getName());
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(BeanELResolver.class.getName());
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(BeanNameELResolver.class.getName());
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ListELResolver.class.getName());
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(MapELResolver.class.getName());
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ResourceBundleELResolver.class.getName());
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(StaticFieldELResolver.class.getName());
>> + // JSP API Resolvers - referenced by name to avoid creating dependency
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("jakarta.servlet.jsp.el.ImplicitObjectELResolver");
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("jakarta.servlet.jsp.el.ScopedAttributeELResolver");
>> + // Tomcat internal resolvers - referenced by name to avoid creating dependency
>> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("org.apache.jasper.el.JasperELResolver$GraalBeanELResolver");
>
> It's not there in 8.5.
Ack. I had the change locally for testing but forgot to commit it. I'll
so that now.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) 04/04: Fix BZ 68119 - Refactor for improved performance during type conversion
Posted by Rémy Maucherat <re...@apache.org>.
On Mon, Nov 27, 2023 at 7:29 PM <ma...@apache.org> wrote:
>
> 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
>
> commit 8df7a3a95babb12fc38b8efa7eb938877ef38485
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Mon Nov 27 14:01:49 2023 +0000
>
> Fix BZ 68119 - Refactor for improved performance during type conversion
>
> https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
> ---
> java/javax/el/CompositeELResolver.java | 47 +++++++++++++++++++++++++++++++---
> webapps/docs/changelog.xml | 8 ++++++
> 2 files changed, 52 insertions(+), 3 deletions(-)
>
> diff --git a/java/javax/el/CompositeELResolver.java b/java/javax/el/CompositeELResolver.java
> index ee14d6bcc3..2280f9a805 100644
> --- a/java/javax/el/CompositeELResolver.java
> +++ b/java/javax/el/CompositeELResolver.java
> @@ -17,13 +17,16 @@
> package javax.el;
>
> import java.beans.FeatureDescriptor;
> +import java.util.HashSet;
> import java.util.Iterator;
> import java.util.NoSuchElementException;
> import java.util.Objects;
> +import java.util.Set;
>
> public class CompositeELResolver extends ELResolver {
>
> private static final Class<?> SCOPED_ATTRIBUTE_EL_RESOLVER;
> + private static final Set<String> KNOWN_NON_TYPE_CONVERTING_RESOLVERS = new HashSet<>();
> static {
> Class<?> clazz = null;
> try {
> @@ -32,15 +35,39 @@ public class CompositeELResolver extends ELResolver {
> // Ignore. This is expected if using the EL stand-alone
> }
> SCOPED_ATTRIBUTE_EL_RESOLVER = clazz;
> +
> + // EL API Resolvers
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ArrayELResolver.class.getName());
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(BeanELResolver.class.getName());
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(BeanNameELResolver.class.getName());
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ListELResolver.class.getName());
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(MapELResolver.class.getName());
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ResourceBundleELResolver.class.getName());
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(StaticFieldELResolver.class.getName());
> + // JSP API Resolvers - referenced by name to avoid creating dependency
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("jakarta.servlet.jsp.el.ImplicitObjectELResolver");
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("jakarta.servlet.jsp.el.ScopedAttributeELResolver");
> + // Tomcat internal resolvers - referenced by name to avoid creating dependency
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("org.apache.jasper.el.JasperELResolver$GraalBeanELResolver");
It's not there in 8.5.
Rémy
> + KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("org.apache.el.stream.StreamELResolverImpl");
> }
>
> private int resolversSize;
> -
> private ELResolver[] resolvers;
>
> + /*
> + * Use a separate array for ELResolvers that might implement type conversion as a performance optimisation. See
> + * https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
> + */
> + private int typeConvertersSize;
> + private ELResolver[] typeConverters;
> +
> public CompositeELResolver() {
> resolversSize = 0;
> resolvers = new ELResolver[8];
> +
> + typeConvertersSize = 0;
> + typeConverters = new ELResolver[0];
> }
>
> public void add(ELResolver elResolver) {
> @@ -56,6 +83,20 @@ public class CompositeELResolver extends ELResolver {
> resolvers = nr;
> }
> resolvers[resolversSize++] = elResolver;
> +
> + if (KNOWN_NON_TYPE_CONVERTING_RESOLVERS.contains(elResolver.getClass().getName())) {
> + // Performance optimisation. ELResolver known not to perform type conversion
> + return;
> + }
> +
> + if (typeConvertersSize == 0) {
> + typeConverters = new ELResolver[1];
> + } else if (typeConvertersSize == typeConverters.length) {
> + ELResolver[] expandedTypeConverters = new ELResolver[typeConvertersSize * 2];
> + System.arraycopy(typeConverters, 0, expandedTypeConverters, 0, typeConvertersSize);
> + typeConverters = expandedTypeConverters;
> + }
> + typeConverters[typeConvertersSize++] = elResolver;
> }
>
> @Override
> @@ -153,9 +194,9 @@ public class CompositeELResolver extends ELResolver {
> @Override
> public Object convertToType(ELContext context, Object obj, Class<?> type) {
> context.setPropertyResolved(false);
> - int sz = this.resolversSize;
> + int sz = typeConvertersSize;
> for (int i = 0; i < sz; i++) {
> - Object result = this.resolvers[i].convertToType(context, obj, type);
> + Object result = this.typeConverters[i].convertToType(context, obj, type);
> if (context.isPropertyResolved()) {
> return result;
> }
> diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
> index 6a2ca0de2f..1fc5a0ec38 100644
> --- a/webapps/docs/changelog.xml
> +++ b/webapps/docs/changelog.xml
> @@ -113,6 +113,14 @@
> </fix>
> </changelog>
> </subsection>
> + <subsection name="Jasper">
> + <changelog>
> + <scode>
> + <bug>68119</bug>: Refactor the <code>CompositeELResolver</code> to
> + improve performance during type conversion operations. (markt)
> + </scode>
> + </changelog>
> + </subsection>
> </section>
> <section name="Tomcat 8.5.96 (schultz)" rtext="Release in progres">
> <subsection name="Catalina">
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 04/04: Fix BZ 68119 - Refactor for improved performance during type conversion
Posted by ma...@apache.org.
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
commit 8df7a3a95babb12fc38b8efa7eb938877ef38485
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 27 14:01:49 2023 +0000
Fix BZ 68119 - Refactor for improved performance during type conversion
https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
---
java/javax/el/CompositeELResolver.java | 47 +++++++++++++++++++++++++++++++---
webapps/docs/changelog.xml | 8 ++++++
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/java/javax/el/CompositeELResolver.java b/java/javax/el/CompositeELResolver.java
index ee14d6bcc3..2280f9a805 100644
--- a/java/javax/el/CompositeELResolver.java
+++ b/java/javax/el/CompositeELResolver.java
@@ -17,13 +17,16 @@
package javax.el;
import java.beans.FeatureDescriptor;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
+import java.util.Set;
public class CompositeELResolver extends ELResolver {
private static final Class<?> SCOPED_ATTRIBUTE_EL_RESOLVER;
+ private static final Set<String> KNOWN_NON_TYPE_CONVERTING_RESOLVERS = new HashSet<>();
static {
Class<?> clazz = null;
try {
@@ -32,15 +35,39 @@ public class CompositeELResolver extends ELResolver {
// Ignore. This is expected if using the EL stand-alone
}
SCOPED_ATTRIBUTE_EL_RESOLVER = clazz;
+
+ // EL API Resolvers
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ArrayELResolver.class.getName());
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(BeanELResolver.class.getName());
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(BeanNameELResolver.class.getName());
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ListELResolver.class.getName());
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(MapELResolver.class.getName());
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(ResourceBundleELResolver.class.getName());
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add(StaticFieldELResolver.class.getName());
+ // JSP API Resolvers - referenced by name to avoid creating dependency
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("jakarta.servlet.jsp.el.ImplicitObjectELResolver");
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("jakarta.servlet.jsp.el.ScopedAttributeELResolver");
+ // Tomcat internal resolvers - referenced by name to avoid creating dependency
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("org.apache.jasper.el.JasperELResolver$GraalBeanELResolver");
+ KNOWN_NON_TYPE_CONVERTING_RESOLVERS.add("org.apache.el.stream.StreamELResolverImpl");
}
private int resolversSize;
-
private ELResolver[] resolvers;
+ /*
+ * Use a separate array for ELResolvers that might implement type conversion as a performance optimisation. See
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=68119
+ */
+ private int typeConvertersSize;
+ private ELResolver[] typeConverters;
+
public CompositeELResolver() {
resolversSize = 0;
resolvers = new ELResolver[8];
+
+ typeConvertersSize = 0;
+ typeConverters = new ELResolver[0];
}
public void add(ELResolver elResolver) {
@@ -56,6 +83,20 @@ public class CompositeELResolver extends ELResolver {
resolvers = nr;
}
resolvers[resolversSize++] = elResolver;
+
+ if (KNOWN_NON_TYPE_CONVERTING_RESOLVERS.contains(elResolver.getClass().getName())) {
+ // Performance optimisation. ELResolver known not to perform type conversion
+ return;
+ }
+
+ if (typeConvertersSize == 0) {
+ typeConverters = new ELResolver[1];
+ } else if (typeConvertersSize == typeConverters.length) {
+ ELResolver[] expandedTypeConverters = new ELResolver[typeConvertersSize * 2];
+ System.arraycopy(typeConverters, 0, expandedTypeConverters, 0, typeConvertersSize);
+ typeConverters = expandedTypeConverters;
+ }
+ typeConverters[typeConvertersSize++] = elResolver;
}
@Override
@@ -153,9 +194,9 @@ public class CompositeELResolver extends ELResolver {
@Override
public Object convertToType(ELContext context, Object obj, Class<?> type) {
context.setPropertyResolved(false);
- int sz = this.resolversSize;
+ int sz = typeConvertersSize;
for (int i = 0; i < sz; i++) {
- Object result = this.resolvers[i].convertToType(context, obj, type);
+ Object result = this.typeConverters[i].convertToType(context, obj, type);
if (context.isPropertyResolved()) {
return result;
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6a2ca0de2f..1fc5a0ec38 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -113,6 +113,14 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <scode>
+ <bug>68119</bug>: Refactor the <code>CompositeELResolver</code> to
+ improve performance during type conversion operations. (markt)
+ </scode>
+ </changelog>
+ </subsection>
</section>
<section name="Tomcat 8.5.96 (schultz)" rtext="Release in progres">
<subsection name="Catalina">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 03/04: Add comment on why >= rather than == is used
Posted by ma...@apache.org.
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
commit 6107ed1d33b3b3a1cd5ee150239b685a3b514c08
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 27 13:47:03 2023 +0000
Add comment on why >= rather than == is used
---
java/javax/el/CompositeELResolver.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/java/javax/el/CompositeELResolver.java b/java/javax/el/CompositeELResolver.java
index dade342c72..ee14d6bcc3 100644
--- a/java/javax/el/CompositeELResolver.java
+++ b/java/javax/el/CompositeELResolver.java
@@ -46,6 +46,10 @@ public class CompositeELResolver extends ELResolver {
public void add(ELResolver elResolver) {
Objects.requireNonNull(elResolver);
+ /*
+ * resolversSize should never be larger than resolvers.length. If it ever is, the code will fail when execution
+ * reaches System.arraycopy with an IndexOutOfBoundsException.
+ */
if (resolversSize >= resolvers.length) {
ELResolver[] nr = new ELResolver[resolversSize * 2];
System.arraycopy(resolvers, 0, nr, 0, resolversSize);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org