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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f4aadf  Reduce else depth
0f4aadf is described below

commit 0f4aadfbff57c8b7a0d4ce1577bcadbe8a5f1435
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Jun 9 08:22:02 2022 -0400

    Reduce else depth
---
 .../java/org/apache/commons/mail/EmailUtils.java   |  2 +-
 .../mail/resolver/DataSourceClassPathResolver.java | 30 ++++++++++------------
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/commons/mail/EmailUtils.java 
b/src/main/java/org/apache/commons/mail/EmailUtils.java
index e3de9f8..1bf9f0c 100644
--- a/src/main/java/org/apache/commons/mail/EmailUtils.java
+++ b/src/main/java/org/apache/commons/mail/EmailUtils.java
@@ -221,7 +221,7 @@ final class EmailUtils
         {
             return "";
         }
-        else if (count < 0)
+        if (count < 0)
         {
             throw new IllegalArgumentException("Requested random string length 
" + count + " is less than 0.");
         }
diff --git 
a/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java
 
b/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java
index 4f1fcdb..a53e051 100644
--- 
a/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java
+++ 
b/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java
@@ -92,29 +92,25 @@ public class DataSourceClassPathResolver extends 
DataSourceBaseResolver
                 final String resourceName = getResourceName(resourceLocation);
                 final InputStream is = 
DataSourceClassPathResolver.class.getResourceAsStream(resourceName);
 
-                if (is != null)
-                {
-                    try
-                    {
-                        final ByteArrayDataSource ds = new 
ByteArrayDataSource(is, mimeType);
-                        // EMAIL-125: set the name of the DataSource to the 
normalized resource URL
-                        // similar to other DataSource implementations, e.g. 
FileDataSource, URLDataSource
-                        
ds.setName(DataSourceClassPathResolver.class.getResource(resourceName).toString());
-                        result = ds;
-                    }
-                    finally
-                    {
-                        is.close();
-                    }
-                }
-                else
-                {
+                if (is == null) {
                     if (isLenient)
                     {
                         return null;
                     }
                     throw new IOException("The following class path resource 
was not found : " + resourceLocation);
                 }
+                try
+                {
+                    final ByteArrayDataSource ds = new ByteArrayDataSource(is, 
mimeType);
+                    // EMAIL-125: set the name of the DataSource to the 
normalized resource URL
+                    // similar to other DataSource implementations, e.g. 
FileDataSource, URLDataSource
+                    
ds.setName(DataSourceClassPathResolver.class.getResource(resourceName).toString());
+                    result = ds;
+                }
+                finally
+                {
+                    is.close();
+                }
             }
 
 

Reply via email to