You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/12/28 14:39:13 UTC

[maven-ear-plugin] branch master updated: compareTo should throw NullPointerException per spec (#35)

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

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new c6acce8  compareTo should throw NullPointerException per spec (#35)
c6acce8 is described below

commit c6acce892910b20305dd87bbdf7bdcfde1d3eb35
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Mon Dec 28 09:39:04 2020 -0500

    compareTo should throw NullPointerException per spec (#35)
    
    * compareTo should throw NullPointerException per spec
    
    * consistent spelling
---
 .../maven/plugins/ear/util/JavaEEVersion.java       | 10 +++++-----
 .../maven/plugins/ear/util/JavaEEVersionTest.java   | 21 +++++----------------
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java b/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
index cff3577..8283822 100644
--- a/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
+++ b/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
@@ -114,12 +114,12 @@ public class JavaEEVersion
     /**
      * Specifies if this version is greater or equal to the specified version.
      * 
-     * @param parmVersion the version to check
+     * @param paramVersion the version to check
      * @return true if this version is greater or equal to <tt>version</tt>
      */
-    public boolean ge( JavaEEVersion parmVersion )
+    public boolean ge( JavaEEVersion paramVersion )
     {
-        return this.compareTo( parmVersion ) >= 0;
+        return this.compareTo( paramVersion ) >= 0;
     }
 
     /**
@@ -176,7 +176,7 @@ public class JavaEEVersion
     {
         if ( paramVersion == null )
         {
-            throw new IllegalArgumentException( "version could not be null." );
+            throw new NullPointerException( "version cannot be null." );
         }
         // @formatter:off
         return VERSION_1_3.equals( paramVersion ) 
@@ -193,7 +193,7 @@ public class JavaEEVersion
     {
         if ( otherVersion == null )
         {
-            throw new IllegalArgumentException( "other object to compare to could not be null." );
+            throw new NullPointerException( "other object to compare to could not be null." );
         }
         return index.compareTo( otherVersion.index );
     }
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java b/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
index 9933b08..ac3070d 100644
--- a/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
@@ -103,16 +103,9 @@ public class JavaEEVersionTest
         assertEquals( "5", JavaEEVersion.FIVE.getVersion() );
     }
 
-    public void testGetJavaEEVersionValid()
+    public void testGetJavaEEVersionValid() throws InvalidJavaEEVersion
     {
-        try
-        {
-            assertEquals( JavaEEVersion.SIX, JavaEEVersion.getJavaEEVersion( "6" ) );
-        }
-        catch ( InvalidJavaEEVersion invalidJavaEEVersion )
-        {
-            fail( "No exception should have been thrown but got [" + invalidJavaEEVersion.getMessage() + "]" );
-        }
+        assertEquals( JavaEEVersion.SIX, JavaEEVersion.getJavaEEVersion( "6" ) );
     }
 
     public void testGetJavaEEVersionInvalid()
@@ -122,24 +115,20 @@ public class JavaEEVersionTest
             JavaEEVersion.getJavaEEVersion( "2.4" );
             fail( "Should have failed to get an invalid version." );
         }
-        catch ( InvalidJavaEEVersion e )
+        catch ( InvalidJavaEEVersion expected )
         {
             // OK
         }
     }
 
-    public void testGetJavaEEVersionNull()
+    public void testGetJavaEEVersionNull() throws InvalidJavaEEVersion
     {
         try
         {
             JavaEEVersion.getJavaEEVersion( null );
             fail( "Should have failed to get a 'null' version." );
         }
-        catch ( InvalidJavaEEVersion e )
-        {
-            fail( "Should have failed with an illegal argument exception instead." );
-        }
-        catch ( IllegalArgumentException e )
+        catch ( NullPointerException expected )
         {
             // OK
         }