Skip to content

Commit 72e75d3

Browse files
authored
Merge pull request #54 from yma96/1.1.x
Fix NPE for files walk
2 parents 86cac22 + a860ee3 commit 72e75d3

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/main/java/org/commonjava/indy/service/archive/controller/ArchiveController.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void generate( HistoricalContentDTO content )
187187
finally
188188
{
189189
buildConfigLocks.remove( buildConfigId );
190-
logger.info( "lock released, buildConfigId {}", buildConfigId );
190+
logger.info( "<<<Lock released for buildConfigId {}", buildConfigId );
191191
}
192192
} );
193193
try
@@ -216,7 +216,7 @@ public void generate( HistoricalContentDTO content )
216216
protected Boolean doGenerate( HistoricalContentDTO content )
217217
{
218218
String buildConfigId = content.getBuildConfigId();
219-
logger.info( "Handle generate event: {}, build config id: {}", EVENT_GENERATE_ARCHIVE, buildConfigId );
219+
logger.info( "<<<Handle generate event: {}, build config id: {}", EVENT_GENERATE_ARCHIVE, buildConfigId );
220220

221221
Map<String, HistoricalEntryDTO> entryDTOs = reader.readEntries( content );
222222
Map<String, String> downloadPaths = new HashMap<>();
@@ -483,10 +483,15 @@ private boolean renderArchive( File part, final String buildConfigId )
483483
public List<File> walkAllFiles( String path )
484484
throws IOException
485485
{
486-
List<File> contents = Files.walk( Paths.get( path ) )
487-
.filter( Files::isRegularFile )
488-
.map( Path::toFile )
489-
.collect( Collectors.toList() );
486+
List<File> contents = new ArrayList<>();
487+
Path directoryPath = Paths.get( path );
488+
if ( Files.exists( directoryPath ) )
489+
{
490+
contents = Files.walk( directoryPath )
491+
.filter( Files::isRegularFile )
492+
.map( Path::toFile )
493+
.collect( Collectors.toList() );
494+
}
490495
return contents;
491496
}
492497

src/main/java/org/commonjava/indy/service/archive/schedule/ArchiveFileCleanup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ArchiveFileCleanup
4747
void cleanup()
4848
throws IOException
4949
{
50-
logger.info( "Start not used archive files cleanup." );
50+
logger.info( "<<<Start not used archive files cleanup." );
5151
String storeDir = preSeedConfig.storageDir().orElse( "data" );
5252
String archiveDir = String.format( "%s%s", storeDir, ARCHIVE_DIR );
5353

@@ -66,7 +66,7 @@ void cleanup()
6666
{
6767
artifact.delete();
6868
logger.info(
69-
"Not used archive files cleanup is finished for archive file: {}, not used days: {}, config: {}.",
69+
"<<<Not used archive files cleanup is finished for archive file: {}, not used days: {}, config: {}.",
7070
artifact.getPath(), days, notUsedDays );
7171
}
7272
}

0 commit comments

Comments
 (0)