Skip to content

Commit

Permalink
Fix NPE for files walk
Browse files Browse the repository at this point in the history
  • Loading branch information
yma96 committed Dec 17, 2024
1 parent d081ec6 commit a860ee3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void generate( HistoricalContentDTO content )
finally
{
buildConfigLocks.remove( buildConfigId );
logger.info( "lock released, buildConfigId {}", buildConfigId );
logger.info( "<<<Lock released for buildConfigId {}", buildConfigId );
}
} );
try
Expand Down Expand Up @@ -216,7 +216,7 @@ public void generate( HistoricalContentDTO content )
protected Boolean doGenerate( HistoricalContentDTO content )
{
String buildConfigId = content.getBuildConfigId();
logger.info( "Handle generate event: {}, build config id: {}", EVENT_GENERATE_ARCHIVE, buildConfigId );
logger.info( "<<<Handle generate event: {}, build config id: {}", EVENT_GENERATE_ARCHIVE, buildConfigId );

Map<String, HistoricalEntryDTO> entryDTOs = reader.readEntries( content );
Map<String, String> downloadPaths = new HashMap<>();
Expand Down Expand Up @@ -483,10 +483,15 @@ private boolean renderArchive( File part, final String buildConfigId )
public List<File> walkAllFiles( String path )
throws IOException
{
List<File> contents = Files.walk( Paths.get( path ) )
.filter( Files::isRegularFile )
.map( Path::toFile )
.collect( Collectors.toList() );
List<File> contents = new ArrayList<>();
Path directoryPath = Paths.get( path );
if ( Files.exists( directoryPath ) )
{
contents = Files.walk( directoryPath )
.filter( Files::isRegularFile )
.map( Path::toFile )
.collect( Collectors.toList() );
}
return contents;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ArchiveFileCleanup
void cleanup()
throws IOException
{
logger.info( "Start not used archive files cleanup." );
logger.info( "<<<Start not used archive files cleanup." );
String storeDir = preSeedConfig.storageDir().orElse( "data" );
String archiveDir = String.format( "%s%s", storeDir, ARCHIVE_DIR );

Expand All @@ -66,7 +66,7 @@ void cleanup()
{
artifact.delete();
logger.info(
"Not used archive files cleanup is finished for archive file: {}, not used days: {}, config: {}.",
"<<<Not used archive files cleanup is finished for archive file: {}, not used days: {}, config: {}.",
artifact.getPath(), days, notUsedDays );
}
}
Expand Down

0 comments on commit a860ee3

Please sign in to comment.