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
The following commit(s) were added to refs/heads/10.1.x by this push: new 898040444a Align with 11.0.x and 12.0.x 898040444a is described below commit 898040444a022c8be8d8ecf2ee209ebae45060e6 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Apr 3 17:49:45 2025 +0100 Align with 11.0.x and 12.0.x --- .../org/apache/naming/factory/DataSourceLinkFactory.java | 16 ++++++++-------- java/org/apache/naming/factory/LookupFactory.java | 3 +-- java/org/apache/naming/factory/MailSessionFactory.java | 4 +--- java/org/apache/naming/factory/OpenEjbFactory.java | 4 +--- java/org/apache/naming/factory/ResourceLinkFactory.java | 3 +-- java/org/apache/naming/factory/SendMailFactory.java | 11 +++++++---- res/checkstyle/org-import-control.xml | 3 ++- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java b/java/org/apache/naming/factory/DataSourceLinkFactory.java index 148160644f..68c39f6c46 100644 --- a/java/org/apache/naming/factory/DataSourceLinkFactory.java +++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java @@ -66,9 +66,9 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { DataSourceHandler handler = new DataSourceHandler((DataSource) datasource, username, password); return Proxy.newProxyInstance(datasource.getClass().getClassLoader(), datasource.getClass().getInterfaces(), handler); - } catch (Exception x) { - if (x instanceof InvocationTargetException) { - Throwable cause = x.getCause(); + } catch (Exception exception) { + if (exception instanceof InvocationTargetException) { + Throwable cause = exception.getCause(); if (cause instanceof ThreadDeath) { throw (ThreadDeath) cause; } @@ -76,14 +76,14 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { throw (VirtualMachineError) cause; } if (cause instanceof Exception) { - x = (Exception) cause; + exception = (Exception) cause; } } - if (x instanceof NamingException) { - throw (NamingException) x; + if (exception instanceof NamingException) { + throw (NamingException) exception; } else { - NamingException nx = new NamingException(x.getMessage()); - nx.initCause(x); + NamingException nx = new NamingException(exception.getMessage()); + nx.initCause(exception); throw nx; } } diff --git a/java/org/apache/naming/factory/LookupFactory.java b/java/org/apache/naming/factory/LookupFactory.java index 881b14d6f2..cf1926d7ed 100644 --- a/java/org/apache/naming/factory/LookupFactory.java +++ b/java/org/apache/naming/factory/LookupFactory.java @@ -25,7 +25,6 @@ import javax.naming.InitialContext; import javax.naming.Name; import javax.naming.NamingException; import javax.naming.RefAddr; -import javax.naming.Reference; import javax.naming.spi.ObjectFactory; import org.apache.juli.logging.Log; @@ -63,7 +62,7 @@ public class LookupFactory implements ObjectFactory { Object result = null; if (obj instanceof LookupRef) { - Reference ref = (Reference) obj; + LookupRef ref = (LookupRef) obj; ObjectFactory factory = null; RefAddr lookupNameRefAddr = ref.get(LookupRef.LOOKUP_NAME); if (lookupNameRefAddr != null) { diff --git a/java/org/apache/naming/factory/MailSessionFactory.java b/java/org/apache/naming/factory/MailSessionFactory.java index 0052b4971d..b822032087 100644 --- a/java/org/apache/naming/factory/MailSessionFactory.java +++ b/java/org/apache/naming/factory/MailSessionFactory.java @@ -123,9 +123,7 @@ public class MailSessionFactory implements ObjectFactory { } // Create and return the new Session object - Session session = Session.getInstance(props, auth); - return session; - + return Session.getInstance(props, auth); }); } } diff --git a/java/org/apache/naming/factory/OpenEjbFactory.java b/java/org/apache/naming/factory/OpenEjbFactory.java index e901f38b46..4826face3e 100644 --- a/java/org/apache/naming/factory/OpenEjbFactory.java +++ b/java/org/apache/naming/factory/OpenEjbFactory.java @@ -23,7 +23,6 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.Name; import javax.naming.RefAddr; -import javax.naming.Reference; import javax.naming.spi.ObjectFactory; import org.apache.naming.EjbRef; @@ -65,8 +64,7 @@ public class OpenEjbFactory implements ObjectFactory { Object beanObj = null; if (obj instanceof EjbRef) { - - Reference ref = (Reference) obj; + EjbRef ref = (EjbRef) obj; String factory = DEFAULT_OPENEJB_FACTORY; RefAddr factoryRefAddr = ref.get("openejb.factory"); diff --git a/java/org/apache/naming/factory/ResourceLinkFactory.java b/java/org/apache/naming/factory/ResourceLinkFactory.java index 93204b1934..8760c0f620 100644 --- a/java/org/apache/naming/factory/ResourceLinkFactory.java +++ b/java/org/apache/naming/factory/ResourceLinkFactory.java @@ -25,7 +25,6 @@ import javax.naming.Context; import javax.naming.Name; import javax.naming.NamingException; import javax.naming.RefAddr; -import javax.naming.Reference; import javax.naming.spi.ObjectFactory; import org.apache.naming.ResourceLinkRef; @@ -135,7 +134,7 @@ public class ResourceLinkFactory implements ObjectFactory { } // Can we process this request? - Reference ref = (Reference) obj; + ResourceLinkRef ref = (ResourceLinkRef) obj; // Read the global ref addr String globalName; diff --git a/java/org/apache/naming/factory/SendMailFactory.java b/java/org/apache/naming/factory/SendMailFactory.java index 638d59f577..4925e9b0a2 100644 --- a/java/org/apache/naming/factory/SendMailFactory.java +++ b/java/org/apache/naming/factory/SendMailFactory.java @@ -33,6 +33,8 @@ import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimePartDataSource; +import org.apache.tomcat.util.ExceptionUtils; + /** * Factory class that creates a JNDI named javamail MimePartDataSource object which can be used for sending email using * SMTP. @@ -97,10 +99,11 @@ public class SendMailFactory implements ObjectFactory { message.setFrom(new InternetAddress(from)); } message.setSubject(""); - } catch (Exception e) { - /* Ignore */} - MimePartDataSource mds = new MimePartDataSource(message); - return mds; + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + // Otherwise ignore + } + return new MimePartDataSource(message); }); } else { // We can't create an instance of the DataSource return null; diff --git a/res/checkstyle/org-import-control.xml b/res/checkstyle/org-import-control.xml index e324564703..3017333bb0 100644 --- a/res/checkstyle/org-import-control.xml +++ b/res/checkstyle/org-import-control.xml @@ -128,6 +128,7 @@ <allow pkg="javax.wsdl"/> <allow pkg="org.apache.juli"/> <allow pkg="org.apache.naming"/> + <allow class="org.apache.tomcat.util.ExceptionUtils"/> <allow class="org.apache.tomcat.util.buf.UDecoder"/> <allow class="org.apache.tomcat.util.buf.UEncoder"/> <allow class="org.apache.tomcat.util.http.FastHttpDateFormat"/> @@ -193,4 +194,4 @@ </subpackage> </subpackage> </subpackage> -</import-control> \ No newline at end of file +</import-control> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org