Adding null checks for index manager

This commit is contained in:
Martin Stockhammer 2019-09-22 00:08:17 +02:00
parent 74d69f36c8
commit d9f8834dc1
1 changed files with 12 additions and 4 deletions

View File

@ -148,6 +148,8 @@ public class MavenIndexManager implements ArchivaIndexManager {
public static IndexingContext getMvnContext( ArchivaIndexingContext context ) throws UnsupportedBaseContextException public static IndexingContext getMvnContext( ArchivaIndexingContext context ) throws UnsupportedBaseContextException
{
if (context!=null)
{ {
if ( !context.supports( IndexingContext.class ) ) if ( !context.supports( IndexingContext.class ) )
{ {
@ -155,6 +157,9 @@ public class MavenIndexManager implements ArchivaIndexManager {
throw new UnsupportedBaseContextException( "The context does not support the Maven IndexingContext" ); throw new UnsupportedBaseContextException( "The context does not support the Maven IndexingContext" );
} }
return context.getBaseContext( IndexingContext.class ); return context.getBaseContext( IndexingContext.class );
} else {
return null;
}
} }
private StorageAsset getIndexPath( ArchivaIndexingContext ctx ) private StorageAsset getIndexPath( ArchivaIndexingContext ctx )
@ -175,6 +180,9 @@ public class MavenIndexManager implements ArchivaIndexManager {
*/ */
private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException
{ {
if (context==null) {
throw new IndexUpdateFailedException( "Given context is null" );
}
IndexingContext indexingContext = null; IndexingContext indexingContext = null;
try try
{ {