HHH-12630 Keep the original starting exception and use it as a cause

This commit is contained in:
Guillaume Smet 2018-06-26 14:20:46 +02:00
parent d0087948ef
commit 163cab99e2
1 changed files with 7 additions and 2 deletions

View File

@ -23,6 +23,8 @@ public abstract class AbstractRegionFactory implements RegionFactory {
private final AtomicBoolean started = new AtomicBoolean( false ); private final AtomicBoolean started = new AtomicBoolean( false );
private Exception startingException;
private SessionFactoryOptions options; private SessionFactoryOptions options;
@ -33,13 +35,13 @@ public abstract class AbstractRegionFactory implements RegionFactory {
} }
else { else {
assert options == null; assert options == null;
throw new IllegalStateException( "Cache provider not started" ); throw new IllegalStateException( "Cache provider not started", startingException );
} }
} }
protected void verifyStarted() { protected void verifyStarted() {
if ( ! verifiedStartStatus() ) { 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; this.options = settings;
try { try {
prepareForUse( settings, configValues ); prepareForUse( settings, configValues );
startingException = null;
} }
catch ( Exception e ) { catch ( Exception e ) {
options = null; options = null;
started.set( false ); started.set( false );
startingException = e;
} }
} }
} }
@ -89,6 +93,7 @@ public abstract class AbstractRegionFactory implements RegionFactory {
} }
finally { finally {
options = null; options = null;
startingException = null;
} }
} }
} }