Uploaded image for project: 'Maven Wagon'
  1. Maven Wagon
  2. WAGON-473

Don't abuse IllegalArgumentException to intercept null input

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.10
    • Fix Version/s: 2.12
    • Component/s: None
    • Labels:
      None

      Description

      In several spots of Maven Wagon IAE is thrown where an argument is null. This should be turned into NullPointerException since JDK adheres to is and the description of this exception indicates that and Effective Java does that too.

      Most likely to be misused:

      $ grep -r "throw new IllegalArgumentException" .
      ./wagon-provider-api/src/main/java/org/apache/maven/wagon/PermissionModeUtils.java:            throw new IllegalArgumentException( "The mode is a number but is not octal" );
      ./wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java:                throw new IllegalArgumentException( "Illegal event type: " + eventType );
      ./wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java:                throw new IllegalArgumentException( "Illegal request type: " + requestType );
      ./wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java:                throw new IllegalArgumentException( "Illegal event type: " + eventType );
      ./wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java:            throw new IllegalArgumentException( "Unrecognised length for binary data: " + bitLength + " bits" );
      ./wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java:            throw new IllegalArgumentException( "Authentication Credentials cannot be null for FTP protocol" );
      ./wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java:            throw new IllegalArgumentException( String.format( "Error parsing url: %s", url ), e );
      ./wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java:                throw new IllegalArgumentException( "Output stream may not be null" );
      ./wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java:            throw new IllegalArgumentException( "Source is a directory: " + source );
      ./wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java:            throw new IllegalArgumentException( "Source is not a directory: " + sourceDirectory );
      ./wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java:            throw new IllegalArgumentException( "Unknown command, does not begin with 'scp'" );
      ./wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java:            throw new IllegalArgumentException( "no Base64 part to decode" );
      ./wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java:            throw new IllegalArgumentException( "unknown type " + type );
      ./wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/PrompterUIKeyboardInteractive.java:            throw new IllegalArgumentException( "prompt and echo size arrays are different!" );
      ./wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java:            throw new IllegalArgumentException( "DAV:multistatus element expected." );
      

        Activity

        Hide
        michael-o Michael Osipov added a comment -

        Fixed with 30631655e8f6cdf121161b3ca09e3da0134a5198.

        Show
        michael-o Michael Osipov added a comment - Fixed with 30631655e8f6cdf121161b3ca09e3da0134a5198.
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Jenkins build maven-wagon #1324 (See https://builds.apache.org/job/maven-wagon/1324/)
        WAGON-473 Don't abuse IllegalArgumentException to intercept null input (michaelo: rev 30631655e8f6cdf121161b3ca09e3da0134a5198)

        • (edit) wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
        • (edit) wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
        • (edit) wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
        • (edit) wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Jenkins build maven-wagon #1324 (See https://builds.apache.org/job/maven-wagon/1324/ ) WAGON-473 Don't abuse IllegalArgumentException to intercept null input (michaelo: rev 30631655e8f6cdf121161b3ca09e3da0134a5198) (edit) wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java (edit) wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java (edit) wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java (edit) wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
        Hide
        michael-o Michael Osipov added a comment -
        Show
        michael-o Michael Osipov added a comment - Follow up fix with 0e3c4f94de032b5ca0f60eee8cc2dc8eca825716 .
        Hide
        hudson Hudson added a comment -

        UNSTABLE: Integrated in Jenkins build maven-wagon #1326 (See https://builds.apache.org/job/maven-wagon/1326/)
        WAGON-473 Don't abuse IllegalArgumentException to intercept null input (michaelo: rev 0e3c4f94de032b5ca0f60eee8cc2dc8eca825716)

        • (edit) wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
        Show
        hudson Hudson added a comment - UNSTABLE: Integrated in Jenkins build maven-wagon #1326 (See https://builds.apache.org/job/maven-wagon/1326/ ) WAGON-473 Don't abuse IllegalArgumentException to intercept null input (michaelo: rev 0e3c4f94de032b5ca0f60eee8cc2dc8eca825716) (edit) wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java

          People

          • Assignee:
            michael-o Michael Osipov
            Reporter:
            michael-o Michael Osipov
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development