Skip to content

Commit

Permalink
JENKINS-32983: fix FindBugs issues
Browse files Browse the repository at this point in the history
ignored two "errors" suspected as being false positive
  • Loading branch information
jcarsique committed Feb 18, 2016
1 parent 7186991 commit 900891e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 32 deletions.
12 changes: 12 additions & 0 deletions src/findbugs/excludesFilter.xml
@@ -0,0 +1,12 @@
<FindBugsFilter>
<Match>
<Class name="org.jenkinsci.plugins.maveninvoker.MavenInvokerArchiver$2" />
<Method name="call" />
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>
<Match>
<Class name="org.jenkinsci.plugins.maveninvoker.MavenInvokerBuildAction" />
<Method name="getMavenInvokerResults" />
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>
</FindBugsFilter>
Expand Up @@ -28,6 +28,7 @@
import hudson.model.Action;
import hudson.model.AbstractBuild;

import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -121,8 +122,10 @@ protected Object readResolve()
public static final MavenInvokerResultComparator COMPARATOR_INSTANCE = new MavenInvokerResultComparator();

public static class MavenInvokerResultComparator
implements Comparator<MavenInvokerResult>
implements Comparator<MavenInvokerResult>, Serializable
{
private static final long serialVersionUID = 1L;

@Override
public int compare( MavenInvokerResult mavenInvokerResult, MavenInvokerResult mavenInvokerResult1 )
{
Expand Down
Expand Up @@ -70,7 +70,7 @@ public boolean postExecute( MavenBuildProxy build, MavenProject pom, MojoInfo mo

final PrintStream logger = listener.getLogger();
logger.println( "MavenInvokerArchiver" );
File[] reports = new File[0];
File[] reports = null;
try
{
// projectsDirectory
Expand All @@ -80,14 +80,17 @@ public boolean postExecute( MavenBuildProxy build, MavenProject pom, MojoInfo mo
final File cloneProjectsTo = mojo.getConfigurationValue( "cloneProjectsTo", File.class );

final File reportsDir = mojo.getConfigurationValue( "reportsDirectory", File.class );
reports = reportsDir.listFiles( new FilenameFilter()
if ( reportsDir != null )
{
@Override
public boolean accept( File file, String s )
reports = reportsDir.listFiles( new FilenameFilter()
{
return s.startsWith( "BUILD" );
}
} );
@Override
public boolean accept( File file, String s )
{
return s.startsWith( "BUILD" );
}
} );
}

if ( reports != null )
{
Expand Down Expand Up @@ -135,7 +138,10 @@ public boolean accept( File file, String s )
public Integer call( MavenBuild aBuild )
throws IOException, IOException, InterruptedException
{

if ( reportsDir == null )
{
return 0;
}
FilePath[] reportsPaths =
MavenInvokerRecorder.locateReports( aBuild.getWorkspace(),
buildDirectory + "/" + reportsDir.getName() + "/BUILD*.xml" );
Expand All @@ -155,10 +161,14 @@ public Integer call( MavenBuild aBuild )

File projectDir = new File( invokerBuildDir, mavenInvokerResult.project );

FilePath[] buildLogs =
MavenInvokerRecorder.locateBuildLogs( aBuild.getWorkspace(), "**/"
+ projectDir.getParentFile().getName() );

FilePath[] buildLogs = null;
File parentFile = projectDir.getParentFile();
if ( parentFile != null )
{
buildLogs =
MavenInvokerRecorder.locateBuildLogs( aBuild.getWorkspace(),
"**/" + parentFile.getName() );
}
if ( buildLogs != null )
{
allBuildLogs.addAll( Arrays.asList( buildLogs ) );
Expand Down
Expand Up @@ -51,9 +51,9 @@ public class MavenInvokerBuildAction
*/
private static final long serialVersionUID = 31415927L;

private Reference<MavenInvokerResults> mavenInvokerResults;
private transient Reference<MavenInvokerResults> mavenInvokerResults;

private final AbstractBuild<?, ?> build;
private transient final AbstractBuild<?, ?> build;

private transient int passedTestCount;

Expand Down
Expand Up @@ -25,7 +25,9 @@
/**
* @author Olivier Lamy
*/
public class MavenInvokerResult implements Serializable {
public class MavenInvokerResult
implements Serializable
{

private static final long serialVersionUID = 1L;

Expand All @@ -44,27 +46,23 @@ public class MavenInvokerResult implements Serializable {

public double time;

public String type;

public String buildLog;

public MavenInvokerResult() {
public MavenInvokerResult()
{
// no op
}

@Override
public String toString() {
public String toString()
{
final StringBuilder sb = new StringBuilder();
sb.append("MavenInvokerResult");
sb.append("{project='").append(project).append('\'');
sb.append(", name='").append(name).append('\'');
sb.append(", description='").append(description).append('\'');
sb.append(", result='").append(result).append('\'');
sb.append(", failureMessage='").append(failureMessage).append('\'');
sb.append(", time=").append(time);
sb.append(", type='").append(type).append('\'');
sb.append(", buildLog='").append(buildLog).append('\'');
sb.append('}');
sb.append( "MavenInvokerResult" );
sb.append( "{project='" ).append( project ).append( '\'' );
sb.append( ", name='" ).append( name ).append( '\'' );
sb.append( ", description='" ).append( description ).append( '\'' );
sb.append( ", result='" ).append( result ).append( '\'' );
sb.append( ", failureMessage='" ).append( failureMessage ).append( '\'' );
sb.append( ", time=" ).append( time );
sb.append( '}' );
return sb.toString();
}

Expand Down

0 comments on commit 900891e

Please sign in to comment.