From 865d5398c203e3772be489fb170dd69dc2beabda Mon Sep 17 00:00:00 2001 From: Radim Vansa Date: Mon, 14 Nov 2016 14:49:04 +0100 Subject: [PATCH] HHH-11226 Hibernate cache throws NullPointerException during wildfly app server startup --- .../cache/infinispan/util/CacheCommandFactory.java | 3 +-- .../hibernate/cache/infinispan/util/EvictAllCommand.java | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheCommandFactory.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheCommandFactory.java index 3a90b655fc..eb3f10f346 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheCommandFactory.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheCommandFactory.java @@ -36,7 +36,6 @@ public class CacheCommandFactory implements ExtendedModuleCommandFactory { /** * Add region so that commands can be cleared on shutdown. * - * @param regionName name of the region * @param region instance to keep track of */ public void addRegion(BaseRegion region) { @@ -46,7 +45,7 @@ public class CacheCommandFactory implements ExtendedModuleCommandFactory { /** * Clear all regions from this command factory. * - * @param regionNames collection of regions to clear + * @param regions collection of regions to clear */ public void clearRegions(Collection regions) { regions.forEach( region -> allRegions.remove( region.getName() ) ); diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/EvictAllCommand.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/EvictAllCommand.java index 9f17d70f78..b22085369d 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/EvictAllCommand.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/EvictAllCommand.java @@ -44,7 +44,11 @@ public class EvictAllCommand extends BaseRpcCommand { @Override public Object perform(InvocationContext ctx) throws Throwable { - region.invalidateRegion(); + // When a node is joining the cluster, it may receive an EvictAllCommand before the regions + // are started up. It's safe to ignore such invalidation at this point since no data got in. + if (region != null) { + region.invalidateRegion(); + } return null; }