diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-09-22 00:08:17 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-09-22 00:08:17 +0200 |
commit | fd48fb51b28d9b603fc3a4b23c37081a460e94a8 (patch) | |
tree | 132348a1d9c3f6020fe8ac52f875a4c22ade9c8b | |
parent | 9148a985c0302cc3dac9179871ec4b2d989c47bc (diff) | |
download | archiva-fd48fb51b28d9b603fc3a4b23c37081a460e94a8.tar.gz archiva-fd48fb51b28d9b603fc3a4b23c37081a460e94a8.zip |
Adding null checks for index manager
-rw-r--r-- | archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java b/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java index 73a890008..4a4ad806b 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java +++ b/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java @@ -149,12 +149,17 @@ public class MavenIndexManager implements ArchivaIndexManager { public static IndexingContext getMvnContext( ArchivaIndexingContext context ) throws UnsupportedBaseContextException { - if ( !context.supports( IndexingContext.class ) ) + if (context!=null) { - log.error( "The provided archiva index context does not support the maven IndexingContext" ); - throw new UnsupportedBaseContextException( "The context does not support the Maven IndexingContext" ); + if ( !context.supports( IndexingContext.class ) ) + { + log.error( "The provided archiva index context does not support the maven IndexingContext" ); + throw new UnsupportedBaseContextException( "The context does not support the Maven IndexingContext" ); + } + return context.getBaseContext( IndexingContext.class ); + } else { + return null; } - return context.getBaseContext( IndexingContext.class ); } private StorageAsset getIndexPath( ArchivaIndexingContext ctx ) @@ -175,6 +180,9 @@ public class MavenIndexManager implements ArchivaIndexManager { */ private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException { + if (context==null) { + throw new IndexUpdateFailedException( "Given context is null" ); + } IndexingContext indexingContext = null; try { |