Author: bentmann Date: Sun Jul 12 09:38:11 2009 New Revision: 793305 URL: http://svn.apache.org/viewvc?rev=793305&view=rev Log: [MNG-3753] ArtifactResolverDiagnoser.diagnose() fails with NPE if nested IOException has no detail message
Added: maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java (with props) Modified: maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java Modified: maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java?rev=793305&r1=793304&r2=793305&view=diff ============================================================================== --- maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java (original) +++ maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java Sun Jul 12 09:38:11 2009 @@ -50,7 +50,7 @@ IOException ioe = (IOException) DiagnosisUtils.getFromCausality( exception, IOException.class ); - if ( ioe != null && exception.getMessage().indexOf( ioe.getMessage() ) < 0 ) + if ( ioe != null && ioe.getMessage() != null && exception.getMessage().indexOf( ioe.getMessage() ) < 0 ) { message.append( "\n\nCaused by I/O exception: " ).append( ioe.getMessage() ); } Added: maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java?rev=793305&view=auto ============================================================================== --- maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java (added) +++ maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java Sun Jul 12 09:38:11 2009 @@ -0,0 +1,53 @@ +package org.apache.maven.usability; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; + +import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.usability.diagnostics.ErrorDiagnoser; +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Benjamin Bentmann + * @version $Id$ + */ +public class ArtifactResolverDiagnoserTest + extends PlexusTestCase +{ + + /** + * Tests that inner IOException without detail message does not crash diagnoser. + * + * @throws Exception + */ + public void testNullMessage() + throws Exception + { + ErrorDiagnoser diagnoser = + (ArtifactResolverDiagnoser) lookup( ErrorDiagnoser.ROLE, "ArtifactResolverDiagnoser" ); + + Throwable error = new ArtifactResolutionException( null, null, null, null, null, null, new IOException() ); + + assertTrue( diagnoser.canDiagnose( error ) ); + diagnoser.diagnose( error ); + } + +} Propchange: maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/maven-2/branches/maven-2.2.x/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision