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." );
      

        Attachments

          Activity

            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: