HHH-11651 - Fix checkstyle errors

This commit is contained in:
Andrea Boriero 2017-09-21 16:24:42 +01:00
parent 5566b423e3
commit 7a897d5285
2 changed files with 36 additions and 22 deletions

View File

@ -71,11 +71,16 @@ public class ConnectionProviderBuilder implements DialectCheck {
try {
Class dataSourceClass = ReflectHelper.classForName( DATA_SOURCE, ConnectionProviderBuilder.class );
DataSource actualDataSource = (DataSource) dataSourceClass.newInstance();
ReflectHelper.findSetterMethod( dataSourceClass, "URL", String.class ).invoke( actualDataSource, String.format( URL, dbName ) );
ReflectHelper.findSetterMethod( dataSourceClass, "URL", String.class ).invoke(
actualDataSource,
String.format( URL, dbName )
);
ReflectHelper.findSetterMethod( dataSourceClass, "user", String.class ).invoke( actualDataSource, USER );
ReflectHelper.findSetterMethod( dataSourceClass, "password", String.class ).invoke( actualDataSource, PASS );
ReflectHelper.findSetterMethod( dataSourceClass, "password", String.class )
.invoke( actualDataSource, PASS );
final DataSourceInvocationHandler dataSourceInvocationHandler = new DataSourceInvocationHandler( actualDataSource );
final DataSourceInvocationHandler dataSourceInvocationHandler = new DataSourceInvocationHandler(
actualDataSource );
DatasourceConnectionProviderImpl connectionProvider = new DatasourceConnectionProviderImpl() {
@Override
@ -85,10 +90,11 @@ public class ConnectionProviderBuilder implements DialectCheck {
};
connectionProvider.configure(
Collections.singletonMap( Environment.DATASOURCE,
Collections.singletonMap(
Environment.DATASOURCE,
Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class[] { DataSource.class },
new Class[] {DataSource.class},
dataSourceInvocationHandler
)
)

View File

@ -368,13 +368,17 @@ public class TransactionUtil {
.openSession();
txn = session.getTransaction();
txn.begin();
function.accept(session);
function.accept( session );
txn.commit();
} catch (Throwable e) {
if ( txn != null ) txn.rollback();
}
catch (Throwable e) {
if ( txn != null ) {
txn.rollback();
}
throw e;
} finally {
if (session != null) {
}
finally {
if ( session != null ) {
session.close();
}
}
@ -402,14 +406,18 @@ public class TransactionUtil {
.openSession();
txn = session.getTransaction();
txn.begin();
R returnValue = function.apply(session);
R returnValue = function.apply( session );
txn.commit();
return returnValue;
} catch (Throwable e) {
if ( txn != null ) txn.rollback();
}
catch (Throwable e) {
if ( txn != null ) {
txn.rollback();
}
throw e;
} finally {
if (session != null) {
}
finally {
if ( session != null ) {
session.close();
}
}