From a2db723186560761c1fdf97be68e798b2ece8ccd Mon Sep 17 00:00:00 2001 From: Gethin James Date: Tue, 8 Aug 2017 15:19:26 +0200 Subject: [PATCH] SEARCH-506: Handling a null properties --- .../solr/tracker/DocRouterFactory.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/tracker/DocRouterFactory.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/tracker/DocRouterFactory.java index 591a05e31..f468f8d3f 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/tracker/DocRouterFactory.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/tracker/DocRouterFactory.java @@ -35,17 +35,20 @@ public class DocRouterFactory public static DocRouter getRouter(Properties properties, ShardMethodEnum method) { - String shardDotId = properties.getProperty("shard.id"); - if (shardDotId != null && !shardDotId.isEmpty()) + if (properties != null) { - try + String shardDotId = properties.getProperty("shard.id"); + if (shardDotId != null && !shardDotId.isEmpty()) { - int shardid = Integer.parseInt(shardDotId); - log.info("Sharding via an ExplicitRouter for shard "+shardid); - return new ExplicitRouter(shardid); - } catch (NumberFormatException e) - { - log.error("Failed to parse a shard.id of "+shardDotId); + try + { + int shardid = Integer.parseInt(shardDotId); + log.info("Sharding via an ExplicitRouter for shard "+shardid); + return new ExplicitRouter(shardid); + } catch (NumberFormatException e) + { + log.error("Failed to parse a shard.id of "+shardDotId); + } } }