Author: aheritier Date: Fri Jul 21 14:44:46 2006 New Revision: 424461 URL: http://svn.apache.org/viewvc?rev=424461&view=rev Log: Avoid using == and != for Objects comparisons
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java maven/maven-1/core/trunk/src/test/java/org/apache/maven/werkz/ProjectTest.java Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java?rev=424461&r1=424460&r2=424461&view=diff ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java Fri Jul 21 14:44:46 2006 @@ -502,7 +502,7 @@ for ( Iterator i = dynaTagPluginMap.keySet().iterator(); i.hasNext(); ) { String uri = (String) i.next(); - if ( dynaTagPluginMap.get( uri ) == housing ) + if ( dynaTagPluginMap.get(uri).equals( housing ) ) { i.remove(); } Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java?rev=424461&r1=424460&r2=424461&view=diff ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java Fri Jul 21 14:44:46 2006 @@ -1049,7 +1049,7 @@ if ( housing != null ) { Project project = housing.getProject(); - if ( baseContext != project.getContext().getParent() ) + if ( !baseContext.equals( project.getContext().getParent() ) ) { log.debug( "Plugin context for " + id + " not initialised for this base context: initialising inside getPluginContext" ); Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java?rev=424461&r1=424460&r2=424461&view=diff ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java Fri Jul 21 14:44:46 2006 @@ -1496,7 +1496,7 @@ public boolean equals( Object o ) { - if ( o == this ) + if ( o.equals( this ) ) { return true; } Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java?rev=424461&r1=424460&r2=424461&view=diff ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java Fri Jul 21 14:44:46 2006 @@ -157,7 +157,7 @@ log.debug( "Artifact [" + path + "] not found in local repository" ); failedDependencies.add( artifact ); } - else if ( artifact.isSnapshot() && artifact.getOverrideType() != Artifact.OVERRIDE_PATH ) + else if ( artifact.isSnapshot() && !Artifact.OVERRIDE_PATH.equals( artifact.getOverrideType() ) ) { // The artifact exists but we need to take into account the user // being online and whether the artifact is a snapshot. If the user @@ -222,7 +222,7 @@ message.append( artifact.getName() ); String overrideType = artifact.getOverrideType(); - if ( overrideType != Artifact.OVERRIDE_NONE ) + if ( !Artifact.OVERRIDE_NONE.equals( overrideType ) ) { if ( Artifact.OVERRIDE_VERSION.equals( overrideType ) ) { @@ -279,7 +279,7 @@ // Since the dependency won't get removed from the failedDependencies list // an error message will be created. String overrideType = artifact.getOverrideType(); - if ( overrideType == Artifact.OVERRIDE_PATH ) + if ( Artifact.OVERRIDE_PATH.equals( overrideType ) ) { continue; } @@ -430,49 +430,26 @@ if ( downloaded ) { - // keep the checksum files from showing up on the download monitor... - if ( listener != null ) - { - wagon.removeTransferListener( listener ); - } - - // try to verify the MD5 checksum for this file. - try - { - verifyChecksum( md5ChecksumObserver, destination, temp, remotePath, ".md5", wagon ); - } - catch ( ChecksumVerificationException e ) - { - // if we catch a ChecksumVerificationException, it means the transfer/read succeeded, but the checksum - // doesn't match. This could be a problem with the server (ibiblio HTTP-200 error page), so we'll - // try this up to two times. On the second try, we'll handle it as a bona-fide error, based on the - // repository's checksum checking policy. - if ( firstRun ) + // keep the checksum files from showing up on the download monitor... + if ( listener != null ) { - log.warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" ); - retry = true; + wagon.removeTransferListener( listener ); } - else - { - throw new ChecksumVerificationException( e.getMessage(), e.getCause() ); - } - } - catch ( ResourceDoesNotExistException md5TryException ) - { - log.debug( "MD5 not found, trying SHA1", md5TryException ); - // if this IS NOT a ChecksumVerificationException, it was a problem with transfer/read of the checksum - // file...we'll try again with the SHA-1 checksum. + // try to verify the MD5 checksum for this file. try { - verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath, ".sha1", wagon ); + verifyChecksum( md5ChecksumObserver, destination, temp, remotePath, ".md5", wagon ); } catch ( ChecksumVerificationException e ) { - // if we also fail to verify based on the SHA-1 checksum, and the checksum transfer/read - // succeeded, then we need to determine whether to retry or handle it as a failure. + // if we catch a ChecksumVerificationException, it means the transfer/read succeeded, but the checksum + // doesn't match. This could be a problem with the server (ibiblio HTTP-200 error page), so we'll + // try this up to two times. On the second try, we'll handle it as a bona-fide error, based on the + // repository's checksum checking policy. if ( firstRun ) { + log.warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" ); retry = true; } else @@ -480,15 +457,37 @@ throw new ChecksumVerificationException( e.getMessage(), e.getCause() ); } } - catch ( ResourceDoesNotExistException sha1TryException ) + catch ( ResourceDoesNotExistException md5TryException ) { - // this was a failed transfer, and we don't want to retry. - throw new ChecksumVerificationException( - "Error retrieving checksum file for " + remotePath, - sha1TryException ); + log.debug( "MD5 not found, trying SHA1", md5TryException ); + + // if this IS NOT a ChecksumVerificationException, it was a problem with transfer/read of the checksum + // file...we'll try again with the SHA-1 checksum. + try + { + verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath, ".sha1", wagon ); + } + catch ( ChecksumVerificationException e ) + { + // if we also fail to verify based on the SHA-1 checksum, and the checksum transfer/read + // succeeded, then we need to determine whether to retry or handle it as a failure. + if ( firstRun ) + { + retry = true; + } + else + { + throw new ChecksumVerificationException( e.getMessage(), e.getCause() ); + } + } + catch ( ResourceDoesNotExistException sha1TryException ) + { + // this was a failed transfer, and we don't want to retry. + throw new ChecksumVerificationException( "Error retrieving checksum file for " + + remotePath, sha1TryException ); + } } } - } // Artifact was found, continue checking additional remote repos (if any) // in case there is a newer version (i.e. snapshots) in another repo @@ -566,7 +565,7 @@ // So we will attempt to do a File.renameTo for efficiency and atomicity, if this fails // then we will use a brute force copy and delete the temporary file. - if ( !temp.renameTo( destination ) && downloaded ) + if ( !temp.renameTo( destination ) && downloaded ) { try { Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java?rev=424461&r1=424460&r2=424461&view=diff ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/Goal.java Fri Jul 21 14:44:46 2006 @@ -239,7 +239,7 @@ */ public void addPreGoalCallback( PreGoalCallback callback ) { - if ( this.preGoalCallbacks == Collections.EMPTY_LIST ) + if ( this.preGoalCallbacks.equals( Collections.EMPTY_LIST ) ) { this.preGoalCallbacks = new ArrayList( 3 ); } Modified: maven/maven-1/core/trunk/src/test/java/org/apache/maven/werkz/ProjectTest.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/test/java/org/apache/maven/werkz/ProjectTest.java?rev=424461&r1=424460&r2=424461&view=diff ============================================================================== --- maven/maven-1/core/trunk/src/test/java/org/apache/maven/werkz/ProjectTest.java (original) +++ maven/maven-1/core/trunk/src/test/java/org/apache/maven/werkz/ProjectTest.java Fri Jul 21 14:44:46 2006 @@ -206,7 +206,7 @@ { firstIndex = i; } - else if ( chain[i] == after ) + else if ( chain[i].equals( after ) ) { afterIndex = i; }