Browse Source

Refined Future exception handling

Issue: SPR-13732
pull/925/merge
Juergen Hoeller 9 years ago
parent
commit
09cea6e6bb
  1. 6
      spring-orm-hibernate5/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java
  2. 9
      spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java

6
spring-orm-hibernate5/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java

@ -340,10 +340,12 @@ public class LocalSessionFactoryBuilder extends Configuration { @@ -340,10 +340,12 @@ public class LocalSessionFactoryBuilder extends Configuration {
return this.sessionFactoryFuture.get();
}
catch (InterruptedException ex) {
throw new IllegalStateException("Interrupted during initialization of Hibernate SessionFactory", ex);
throw new IllegalStateException("Interrupted during initialization of Hibernate SessionFactory: " +
ex.getMessage());
}
catch (ExecutionException ex) {
throw new IllegalStateException("Failed to asynchronously initialize Hibernate SessionFactory", ex);
throw new IllegalStateException("Failed to asynchronously initialize Hibernate SessionFactory: " +
ex.getMessage(), ex.getCause());
}
}
}

9
spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java

@ -366,7 +366,6 @@ public abstract class AbstractEntityManagerFactoryBean implements @@ -366,7 +366,6 @@ public abstract class AbstractEntityManagerFactoryBean implements
// application-managed EntityManager proxy that automatically joins
// existing transactions.
this.entityManagerFactory = createEntityManagerFactoryProxy(this.nativeEntityManagerFactory);
System.out.println("Returning: " + System.currentTimeMillis());
}
private EntityManagerFactory buildNativeEntityManagerFactory() {
@ -381,7 +380,6 @@ public abstract class AbstractEntityManagerFactoryBean implements @@ -381,7 +380,6 @@ public abstract class AbstractEntityManagerFactoryBean implements
if (logger.isInfoEnabled()) {
logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'");
}
System.out.println("Done: " + System.currentTimeMillis());
return emf;
}
@ -481,15 +479,16 @@ public abstract class AbstractEntityManagerFactoryBean implements @@ -481,15 +479,16 @@ public abstract class AbstractEntityManagerFactoryBean implements
return this.nativeEntityManagerFactory;
}
else {
System.out.println("Requested: " + System.currentTimeMillis());
try {
return this.nativeEntityManagerFactoryFuture.get();
}
catch (InterruptedException ex) {
throw new IllegalStateException("Interrupted during initialization of native EntityManagerFactory", ex);
throw new IllegalStateException("Interrupted during initialization of native EntityManagerFactory: " +
ex.getMessage());
}
catch (ExecutionException ex) {
throw new IllegalStateException("Failed to asynchronously initialize native EntityManagerFactory", ex);
throw new IllegalStateException("Failed to asynchronously initialize native EntityManagerFactory: " +
ex.getMessage(), ex.getCause());
}
}
}

Loading…
Cancel
Save