Test for empty locations and avoid printing them

This commit is contained in:
Michael Osipov 2021-01-30 22:48:14 +01:00
parent bb916d0784
commit ceb08cfa77
8 changed files with 40 additions and 17 deletions

View File

@ -153,7 +153,13 @@ class DefaultProblem
buffer.append( '[' ).append( getSeverity() ).append( "] " );
buffer.append( getMessage() );
buffer.append( " @ " ).append( getLocation() );
String location = getLocation();
if ( !location.isEmpty() )
{
buffer.append( " @ " );
buffer.append( location );
}
return buffer.toString();
}

View File

@ -163,7 +163,7 @@ public class DefaultExceptionHandler
String location = ModelProblemUtils.formatLocation( problem, projectId );
if ( StringUtils.isNotEmpty( location ) )
if ( !location.isEmpty() )
{
message += " @ " + location;
}

View File

@ -1154,16 +1154,11 @@ public class MavenProject
sb.append( getArtifactId() );
sb.append( ':' );
sb.append( getVersion() );
sb.append( " @ " );
try
if ( getFile() != null )
{
sb.append( " @ " );
sb.append( getFile().getPath() );
}
catch ( NullPointerException e )
{
// don't log it.
}
return sb.toString();
}

View File

@ -135,8 +135,12 @@ public class ProjectBuildingException
writer.print( problem.getSeverity() );
writer.print( "] " );
writer.print( problem.getMessage() );
writer.print( " @ " );
writer.println( ModelProblemUtils.formatLocation( problem, result.getProjectId() ) );
String location = ModelProblemUtils.formatLocation( problem, result.getProjectId() );
if ( !location.isEmpty() )
{
writer.print( " @ " );
writer.println( location );
}
}
}
}

View File

@ -168,7 +168,12 @@ public class DefaultModelProblem
buffer.append( '[' ).append( getSeverity() ).append( "] " );
buffer.append( getMessage() );
buffer.append( " @ " ).append( ModelProblemUtils.formatLocation( this, null ) );
String location = ModelProblemUtils.formatLocation( this, null );
if ( !location.isEmpty() )
{
buffer.append( " @ " );
buffer.append( location );
}
return buffer.toString();
}

View File

@ -170,8 +170,12 @@ public class ModelBuildingException
writer.print( problem.getSeverity() );
writer.print( "] " );
writer.print( problem.getMessage() );
writer.print( " @ " );
writer.println( ModelProblemUtils.formatLocation( problem, modelId ) );
String location = ModelProblemUtils.formatLocation( problem, modelId );
if ( !location.isEmpty() )
{
writer.print( " @ " );
writer.println( location );
}
}
return buffer.toString();

View File

@ -158,7 +158,12 @@ public class DefaultSettingsProblem
buffer.append( '[' ).append( getSeverity() ).append( "] " );
buffer.append( getMessage() );
buffer.append( " @ " ).append( getLocation() );
String location = getLocation();
if ( !location.isEmpty() )
{
buffer.append( " @ " );
buffer.append( location );
}
return buffer.toString();
}

View File

@ -80,8 +80,12 @@ public class SettingsBuildingException
writer.print( problem.getSeverity() );
writer.print( "] " );
writer.print( problem.getMessage() );
writer.print( " @ " );
writer.println( problem.getLocation() );
String location = problem.getLocation();
if ( !location.isEmpty() )
{
writer.print( " @ " );
writer.println( location );
}
}
return buffer.toString();