From 163cab99e2f0d4a497bb5953727ec3f259a7fc81 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 26 Jun 2018 14:20:46 +0200 Subject: [PATCH] HHH-12630 Keep the original starting exception and use it as a cause --- .../org/hibernate/cache/spi/AbstractRegionFactory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java index 5739afbff2..d2ab7a6d2c 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java @@ -23,6 +23,8 @@ public abstract class AbstractRegionFactory implements RegionFactory { private final AtomicBoolean started = new AtomicBoolean( false ); + private Exception startingException; + private SessionFactoryOptions options; @@ -33,13 +35,13 @@ public abstract class AbstractRegionFactory implements RegionFactory { } else { assert options == null; - throw new IllegalStateException( "Cache provider not started" ); + throw new IllegalStateException( "Cache provider not started", startingException ); } } protected void verifyStarted() { if ( ! verifiedStartStatus() ) { - throw new IllegalStateException( "Cache provider not started" ); + throw new IllegalStateException( "Cache provider not started", startingException ); } } @@ -66,10 +68,12 @@ public abstract class AbstractRegionFactory implements RegionFactory { this.options = settings; try { prepareForUse( settings, configValues ); + startingException = null; } catch ( Exception e ) { options = null; started.set( false ); + startingException = e; } } } @@ -89,6 +93,7 @@ public abstract class AbstractRegionFactory implements RegionFactory { } finally { options = null; + startingException = null; } } }