(tomcat) 01/02: Remove unnecessary code

2023-11-24 Thread markt
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 3c74235c1313bab662512acbd59335b1375cc529
Author: Mark Thomas 
AuthorDate: Fri Nov 24 17:07:45 2023 +

Remove unnecessary code
---
 java/org/apache/catalina/startup/HostConfig.java | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index 067d4dab58..8b5da43a4c 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1676,10 +1676,8 @@ public class HostConfig implements LifecycleListener {
  */
 public void check(String name) {
 synchronized (host) {
-if (host instanceof Lifecycle) {
-if (!((Lifecycle) host).getState().isAvailable()) {
-return;
-}
+if (!((Lifecycle) host).getState().isAvailable()) {
+return;
 }
 if (tryAddServiced(name)) {
 try {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/02: Remove unnecessary code

2023-11-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 172571caced9000cdf4c42b807aadea1a661a3b4
Author: Mark Thomas 
AuthorDate: Fri Nov 24 17:07:45 2023 +

Remove unnecessary code
---
 java/org/apache/catalina/startup/HostConfig.java | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index f626961d94..dcb1e5c9b3 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1683,10 +1683,8 @@ public class HostConfig implements LifecycleListener {
  */
 public void check(String name) {
 synchronized (host) {
-if (host instanceof Lifecycle) {
-if (!((Lifecycle) host).getState().isAvailable()) {
-return;
-}
+if (!((Lifecycle) host).getState().isAvailable()) {
+return;
 }
 if (tryAddServiced(name)) {
 try {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/02: Remove unnecessary code

2023-11-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit a008e060ae308f42c6d1a71c985d38a7ee8b45b5
Author: Mark Thomas 
AuthorDate: Fri Nov 24 17:07:45 2023 +

Remove unnecessary code
---
 java/org/apache/catalina/startup/HostConfig.java | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index fecfb3fc49..43b8d46b25 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1725,10 +1725,8 @@ public class HostConfig implements LifecycleListener {
  */
 public void check(String name) {
 synchronized (host) {
-if (host instanceof Lifecycle) {
-if (!((Lifecycle) host).getState().isAvailable()) {
-return;
-}
+if (!((Lifecycle) host).getState().isAvailable()) {
+return;
 }
 if (tryAddServiced(name)) {
 try {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2023-10-24 Thread markt
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

commit df7823dc9c7f213923d89096ff31f10622740192
Author: Mark Thomas 
AuthorDate: Tue Oct 24 21:42:44 2023 +0100

Remove unnecessary code
---
 java/org/apache/catalina/filters/CorsFilter.java| 2 +-
 java/org/apache/catalina/manager/StatusTransformer.java | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/filters/CorsFilter.java 
b/java/org/apache/catalina/filters/CorsFilter.java
index 33f5d9d59d..1f063aa4c4 100644
--- a/java/org/apache/catalina/filters/CorsFilter.java
+++ b/java/org/apache/catalina/filters/CorsFilter.java
@@ -324,7 +324,7 @@ public class CorsFilter extends GenericFilter {
 if (!isAnyOriginAllowed()) {
 // If only specific origins are allowed, the response will vary by
 // origin
-ResponseUtil.addVaryFieldName(response, 
CorsFilter.REQUEST_HEADER_ORIGIN);
+ResponseUtil.addVaryFieldName(response, REQUEST_HEADER_ORIGIN);
 }
 
 // Let request pass.
diff --git a/java/org/apache/catalina/manager/StatusTransformer.java 
b/java/org/apache/catalina/manager/StatusTransformer.java
index 3aa7f3e922..3b02474605 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -282,8 +282,8 @@ public class StatusTransformer {
 }
 String name = objectName.getKeyProperty("name");
 // use StatusTransformer to output status
-StatusTransformer.writeConnectorState(writer, objectName, name, 
mBeanServer, globalRequestProcessors,
-requestProcessors, mode, args);
+writeConnectorState(
+writer, objectName, name, mBeanServer, 
globalRequestProcessors, requestProcessors, mode, args);
 }
 if (mode == 2) {
 writer.append(']').println();


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-12 Thread markt
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 1533b42a103580844a4618fe809a812de2981493
Author: Mark Thomas 
AuthorDate: Tue May 11 21:49:07 2021 +0100

Remove unnecessary code

This method is called for a SimpleTag.
pushBodyCountVar is always null for SimpleTag as the code where it is
set in visit(CustomTag) is never called if n.implementsSimpleTag() is
true.
---
 java/org/apache/jasper/compiler/Generator.java | 4 
 webapps/docs/changelog.xml | 8 
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index a48494f..fbe1d96 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -3281,10 +3281,6 @@ class Generator {
 boolean tmpIsFragment = isFragment;
 isFragment = true;
 String pushBodyCountVarSave = pushBodyCountVar;
-if (pushBodyCountVar != null) {
-// Use a fixed name for push body count, to simplify code gen
-pushBodyCountVar = "_jspx_push_body_count";
-}
 visitBody(n);
 out = outSave;
 parent = tmpParent;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index dfcabe1..cd2f951 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -104,6 +104,14 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Review code used to generate Java source from JSPs and tags and remove
+code found to be unnecessary. (markt)
+  
+
+  
 
 
   

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-08 Thread markt
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 92e8ba07dca280b9ad391003c8dc8c0eb5e08aef
Author: Mark Thomas 
AuthorDate: Fri May 7 16:09:13 2021 +0100

Remove unnecessary code

Since attr.isDeferredInput() -> tai != null then tai can't be null here
---
 java/org/apache/jasper/compiler/Generator.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index b941532..9e1c97e 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -3049,14 +3049,13 @@ class Generator {
 // should the expression be evaluated before passing to
 // the setter?
 boolean evaluate = false;
-if (tai != null && tai.canBeRequestTime()) {
+if (tai.canBeRequestTime()) {
 evaluate = true; // JSP.2.3.2
 }
 if (attr.isDeferredInput()) {
 evaluate = false; // JSP.2.3.3
 }
-if (attr.isDeferredInput() && tai != null &&
-tai.canBeRequestTime()) {
+if (attr.isDeferredInput() && tai.canBeRequestTime()) {
 evaluate = !attrValue.contains("#{"); // JSP.2.3.5
 }
 if (evaluate) {

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-08 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 935f021373f3c3a4fa9968de5dfbcb1ec7d56d86
Author: Mark Thomas 
AuthorDate: Fri May 7 16:09:13 2021 +0100

Remove unnecessary code

Since attr.isDeferredInput() -> tai != null then tai can't be null here
---
 java/org/apache/jasper/compiler/Generator.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 762bb68..8aa5182 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -3081,14 +3081,13 @@ class Generator {
 // should the expression be evaluated before passing to
 // the setter?
 boolean evaluate = false;
-if (tai != null && tai.canBeRequestTime()) {
+if (tai.canBeRequestTime()) {
 evaluate = true; // JSP.2.3.2
 }
 if (attr.isDeferredInput()) {
 evaluate = false; // JSP.2.3.3
 }
-if (attr.isDeferredInput() && tai != null &&
-tai.canBeRequestTime()) {
+if (attr.isDeferredInput() && tai.canBeRequestTime()) {
 evaluate = !attrValue.contains("#{"); // JSP.2.3.5
 }
 if (evaluate) {

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-08 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit aace69ecff8551ba6b53f0c01d1fedf95228af16
Author: Mark Thomas 
AuthorDate: Fri May 7 16:09:13 2021 +0100

Remove unnecessary code

Since attr.isDeferredInput() -> tai != null then tai can't be null here
---
 java/org/apache/jasper/compiler/Generator.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 66c64e4..2f2e6b8 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -3068,14 +3068,13 @@ class Generator {
 // should the expression be evaluated before passing to
 // the setter?
 boolean evaluate = false;
-if (tai != null && tai.canBeRequestTime()) {
+if (tai.canBeRequestTime()) {
 evaluate = true; // JSP.2.3.2
 }
 if (attr.isDeferredInput()) {
 evaluate = false; // JSP.2.3.3
 }
-if (attr.isDeferredInput() && tai != null &&
-tai.canBeRequestTime()) {
+if (attr.isDeferredInput() && tai.canBeRequestTime()) {
 evaluate = !attrValue.contains("#{"); // JSP.2.3.5
 }
 if (evaluate) {

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-07 Thread markt
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 ac71964d4b53f6833f14c6411cbf9406901c21ca
Author: Mark Thomas 
AuthorDate: Thu May 6 17:37:19 2021 +0100

Remove unnecessary code

If an attribute value is null, it must be a named attribute.
---
 java/org/apache/jasper/compiler/Generator.java | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index aefe232..0c0c6dc 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2963,17 +2963,14 @@ class Generator {
 
 String attrValue = attr.getValue();
 if (attrValue == null) {
-if (attr.isNamedAttribute()) {
-if (n.checkIfAttributeIsJspFragment(attr.getName())) {
-// XXX - no need to generate temporary variable here
-attrValue = generateNamedAttributeJspFragment(attr
-.getNamedAttributeNode(), tagHandlerVar);
-} else {
-attrValue = generateNamedAttributeValue(attr
-.getNamedAttributeNode());
-}
+// Must be a named attribute
+if (n.checkIfAttributeIsJspFragment(attr.getName())) {
+// XXX - no need to generate temporary variable here
+attrValue = generateNamedAttributeJspFragment(attr
+.getNamedAttributeNode(), tagHandlerVar);
 } else {
-return null;
+attrValue = generateNamedAttributeValue(attr
+.getNamedAttributeNode());
 }
 }
 

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-07 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit a6eaeaa4d6742b6af4f988c5ed0edc1978efe217
Author: Mark Thomas 
AuthorDate: Thu May 6 17:37:19 2021 +0100

Remove unnecessary code

If an attribute value is null, it must be a named attribute.
---
 java/org/apache/jasper/compiler/Generator.java | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 860aeb9..82238c9 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2995,17 +2995,14 @@ class Generator {
 
 String attrValue = attr.getValue();
 if (attrValue == null) {
-if (attr.isNamedAttribute()) {
-if (n.checkIfAttributeIsJspFragment(attr.getName())) {
-// XXX - no need to generate temporary variable here
-attrValue = generateNamedAttributeJspFragment(attr
-.getNamedAttributeNode(), tagHandlerVar);
-} else {
-attrValue = generateNamedAttributeValue(attr
-.getNamedAttributeNode());
-}
+// Must be a named attribute
+if (n.checkIfAttributeIsJspFragment(attr.getName())) {
+// XXX - no need to generate temporary variable here
+attrValue = generateNamedAttributeJspFragment(attr
+.getNamedAttributeNode(), tagHandlerVar);
 } else {
-return null;
+attrValue = generateNamedAttributeValue(attr
+.getNamedAttributeNode());
 }
 }
 

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-05-07 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit a79ffed8bded9a68ee17a7c4fba98cb8d8b754b2
Author: Mark Thomas 
AuthorDate: Thu May 6 17:37:19 2021 +0100

Remove unnecessary code

If an attribute value is null, it must be a named attribute.
---
 java/org/apache/jasper/compiler/Generator.java | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 474ac5c..5100bae 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2982,17 +2982,14 @@ class Generator {
 
 String attrValue = attr.getValue();
 if (attrValue == null) {
-if (attr.isNamedAttribute()) {
-if (n.checkIfAttributeIsJspFragment(attr.getName())) {
-// XXX - no need to generate temporary variable here
-attrValue = generateNamedAttributeJspFragment(attr
-.getNamedAttributeNode(), tagHandlerVar);
-} else {
-attrValue = generateNamedAttributeValue(attr
-.getNamedAttributeNode());
-}
+// Must be a named attribute
+if (n.checkIfAttributeIsJspFragment(attr.getName())) {
+// XXX - no need to generate temporary variable here
+attrValue = generateNamedAttributeJspFragment(attr
+.getNamedAttributeNode(), tagHandlerVar);
 } else {
-return null;
+attrValue = generateNamedAttributeValue(attr
+.getNamedAttributeNode());
 }
 }
 

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-04-20 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6c1e1e5360d97aa4856751ea6b5e1874df51c176
Author: Mark Thomas 
AuthorDate: Tue Apr 20 18:36:59 2021 +0100

Remove unnecessary code
---
 java/org/apache/jasper/compiler/Generator.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 664e054..342d502 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2105,7 +2105,7 @@ class Generator {
 String text = n.getText();
 // If the extended option is being used attempt to minimize the
 // frequency of regex operations.
-if ((ctxt != null) && 
ctxt.getOptions().getTrimSpaces().equals(TrimSpacesOption.EXTENDED) &&
+if 
(ctxt.getOptions().getTrimSpaces().equals(TrimSpacesOption.EXTENDED) &&
 text.contains("\n")) {
 // Ensure there are no  or  tags embedded in this
 // text - if there are, we want to NOT modify the whitespace.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code

2021-04-20 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 5ec77a49fd123c3b46e1a015a18e8bc6fe89aa13
Author: Mark Thomas 
AuthorDate: Tue Apr 20 18:36:59 2021 +0100

Remove unnecessary code
---
 java/org/apache/jasper/compiler/Generator.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 3fdf3c4..873646a 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2092,7 +2092,7 @@ class Generator {
 String text = n.getText();
 // If the extended option is being used attempt to minimize the
 // frequency of regex operations.
-if ((ctxt != null) && 
ctxt.getOptions().getTrimSpaces().equals(TrimSpacesOption.EXTENDED) &&
+if 
(ctxt.getOptions().getTrimSpaces().equals(TrimSpacesOption.EXTENDED) &&
 text.contains("\n")) {
 // Ensure there are no  or  tags embedded in this
 // text - if there are, we want to NOT modify the whitespace.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code.

2019-10-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit c5b3ee58258bef44736410be3ae59038b918235f
Author: Mark Thomas 
AuthorDate: Thu Oct 3 21:49:34 2019 +0100

Remove unnecessary code.

In Java 8 and earlier this code is never reached as the findWrapper
method either returns the right constructor or throws an Exception.

In Java 9 the code might return a constructor when it should throw a
MethodNotFoundException but it will then throw IllegalAccessExceptioni
when the constructor is used.
This will be fixed shortly in a future commit.
---
 java/javax/el/Util.java | 25 +
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/java/javax/el/Util.java b/java/javax/el/Util.java
index cfe0c06..7302fe8 100644
--- a/java/javax/el/Util.java
+++ b/java/javax/el/Util.java
@@ -593,29 +593,22 @@ class Util {
 
 List wrappers = Wrapper.wrap(constructors);
 
-Wrapper result = findWrapper(clazz, wrappers, methodName, paramTypes, 
paramValues);
+Wrapper wrapper = findWrapper(clazz, wrappers, methodName, paramTypes, 
paramValues);
 
-return getConstructor(clazz, (Constructor) result.unWrap());
+Constructor constructor = getConstructor(clazz, (Constructor) 
wrapper.unWrap());
+if (constructor == null) {
+throw new MethodNotFoundException(message(
+null, "util.method.notfound", clazz, methodName,
+paramString(paramTypes)));
+}
+return constructor;
 }
 
 
 static Constructor getConstructor(Class type, Constructor c) {
-if (c == null || Modifier.isPublic(type.getModifiers())) {
+if (Modifier.isPublic(type.getModifiers())) {
 return c;
 }
-Constructor cp = null;
-Class sup = type.getSuperclass();
-if (sup != null) {
-try {
-cp = sup.getConstructor(c.getParameterTypes());
-cp = getConstructor(cp.getDeclaringClass(), cp);
-if (cp != null) {
-return cp;
-}
-} catch (NoSuchMethodException e) {
-// Ignore
-}
-}
 return null;
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code.

2019-10-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit da13ef9a06d5f310122340dcf0c7549dc34d3623
Author: Mark Thomas 
AuthorDate: Thu Oct 3 21:49:34 2019 +0100

Remove unnecessary code.

In Java 8 and earlier this code is never reached as the findWrapper
method either returns the right constructor or throws an Exception.

In Java 9 the code might return a constructor when it should throw a
MethodNotFoundException but it will then throw IllegalAccessExceptioni
when the constructor is used.
This will be fixed shortly in a future commit.
---
 java/javax/el/Util.java | 25 +
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/java/javax/el/Util.java b/java/javax/el/Util.java
index 31d7e56..f0a9f6f 100644
--- a/java/javax/el/Util.java
+++ b/java/javax/el/Util.java
@@ -591,29 +591,22 @@ class Util {
 
 List wrappers = Wrapper.wrap(constructors);
 
-Wrapper result = findWrapper(clazz, wrappers, methodName, paramTypes, 
paramValues);
+Wrapper wrapper = findWrapper(clazz, wrappers, methodName, paramTypes, 
paramValues);
 
-return getConstructor(clazz, (Constructor) result.unWrap());
+Constructor constructor = getConstructor(clazz, (Constructor) 
wrapper.unWrap());
+if (constructor == null) {
+throw new MethodNotFoundException(message(
+null, "util.method.notfound", clazz, methodName,
+paramString(paramTypes)));
+}
+return constructor;
 }
 
 
 static Constructor getConstructor(Class type, Constructor c) {
-if (c == null || Modifier.isPublic(type.getModifiers())) {
+if (Modifier.isPublic(type.getModifiers())) {
 return c;
 }
-Constructor cp = null;
-Class sup = type.getSuperclass();
-if (sup != null) {
-try {
-cp = sup.getConstructor(c.getParameterTypes());
-cp = getConstructor(cp.getDeclaringClass(), cp);
-if (cp != null) {
-return cp;
-}
-} catch (NoSuchMethodException e) {
-// Ignore
-}
-}
 return null;
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Remove unnecessary code.

2019-10-04 Thread markt
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 837eb2e14d7ac84cf8bc4e4c78c452f280afa8ad
Author: Mark Thomas 
AuthorDate: Thu Oct 3 21:49:34 2019 +0100

Remove unnecessary code.

In Java 8 and earlier this code is never reached as the findWrapper
method either returns the right constructor or throws an Exception.

In Java 9 the code might return a constructor when it should throw a
MethodNotFoundException but it will then throw IllegalAccessExceptioni
when the constructor is used.
This will be fixed shortly in a future commit.
---
 java/javax/el/Util.java | 25 +
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/java/javax/el/Util.java b/java/javax/el/Util.java
index 0ec663c..4e3880f 100644
--- a/java/javax/el/Util.java
+++ b/java/javax/el/Util.java
@@ -593,29 +593,22 @@ class Util {
 
 List wrappers = Wrapper.wrap(constructors);
 
-Wrapper result = findWrapper(clazz, wrappers, methodName, paramTypes, 
paramValues);
+Wrapper wrapper = findWrapper(clazz, wrappers, methodName, paramTypes, 
paramValues);
 
-return getConstructor(clazz, (Constructor) result.unWrap());
+Constructor constructor = getConstructor(clazz, (Constructor) 
wrapper.unWrap());
+if (constructor == null) {
+throw new MethodNotFoundException(message(
+null, "util.method.notfound", clazz, methodName,
+paramString(paramTypes)));
+}
+return constructor;
 }
 
 
 static Constructor getConstructor(Class type, Constructor c) {
-if (c == null || Modifier.isPublic(type.getModifiers())) {
+if (Modifier.isPublic(type.getModifiers())) {
 return c;
 }
-Constructor cp = null;
-Class sup = type.getSuperclass();
-if (sup != null) {
-try {
-cp = sup.getConstructor(c.getParameterTypes());
-cp = getConstructor(cp.getDeclaringClass(), cp);
-if (cp != null) {
-return cp;
-}
-} catch (NoSuchMethodException e) {
-// Ignore
-}
-}
 return null;
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org