Skip to content

Commit 4bdfb2d

Browse files
committed
clean up warnings in BaseCoreFunctionalTestCase
1 parent 7a04ba3 commit 4bdfb2d

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.hibernate.engine.spi.SessionFactoryImplementor;
3737
import org.hibernate.engine.spi.SessionImplementor;
3838
import org.hibernate.internal.build.AllowSysOut;
39-
import org.hibernate.internal.util.PropertiesHelper;
4039
import org.hibernate.internal.util.ReflectHelper;
4140
import org.hibernate.internal.util.StringHelper;
4241
import org.hibernate.internal.util.config.ConfigurationHelper;
@@ -109,7 +108,6 @@ protected Session openSession(Interceptor interceptor) throws HibernateException
109108
// before/after test class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110109

111110
@BeforeClassOnce
112-
@SuppressWarnings( {"UnusedDeclaration"})
113111
protected void buildSessionFactory() {
114112
buildSessionFactory( null );
115113
}
@@ -384,7 +382,8 @@ protected void prepareTest() throws Exception {
384382
public final void afterTest() throws Exception {
385383
// see https://github.com/hibernate/hibernate-orm/pull/3412#issuecomment-678338398
386384
if ( getDialect() instanceof H2Dialect ) {
387-
ReflectHelper.getMethod( Class.forName( "org.h2.util.DateTimeUtils" ), "resetCalendar" ).invoke( null );
385+
ReflectHelper.getMethod( Class.forName( "org.h2.util.DateTimeUtils" ), "resetCalendar" )
386+
.invoke( null );
388387
}
389388

390389
completeStrayTransaction();
@@ -449,7 +448,7 @@ protected void cleanupTestData() throws Exception {
449448
// Because of https://hibernate.atlassian.net/browse/HHH-5529,
450449
// we can't rely on a Bulk Delete query which will not clear the link tables in @ElementCollection or unidirectional collections
451450
doInHibernate( this::sessionFactory, s -> {
452-
s.createQuery( "from java.lang.Object" ).list().forEach( s::remove );
451+
s.createQuery( "from java.lang.Object", Object.class ).list().forEach( s::remove );
453452
} );
454453
}
455454
}
@@ -472,7 +471,6 @@ public void execute(Connection connection) throws SQLException {
472471
protected void cleanupTest() throws Exception {
473472
}
474473

475-
@SuppressWarnings( {"UnnecessaryBoxing", "UnnecessaryUnboxing"})
476474
@AllowSysOut
477475
protected void assertAllDataRemoved() {
478476
if ( !createSchema() ) {
@@ -486,9 +484,9 @@ protected void assertAllDataRemoved() {
486484
Transaction transaction = tmpSession.beginTransaction();
487485
try {
488486

489-
List list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();
487+
List<?> list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();
490488

491-
Map<String,Integer> items = new HashMap<String,Integer>();
489+
Map<String,Integer> items = new HashMap<>();
492490
if ( !list.isEmpty() ) {
493491
for ( Object element : list ) {
494492
Integer l = items.get( tmpSession.getEntityName( element ) );
@@ -500,7 +498,7 @@ protected void assertAllDataRemoved() {
500498
System.out.println( "Data left: " + element );
501499
}
502500
transaction.rollback();
503-
fail( "Data is left in the database: " + items.toString() );
501+
fail( "Data is left in the database: " + items );
504502
}
505503
transaction.rollback();
506504
}
@@ -519,28 +517,17 @@ protected void assertAllDataRemoved() {
519517

520518
protected boolean readCommittedIsolationMaintained(String scenario) {
521519
int isolation = Connection.TRANSACTION_READ_UNCOMMITTED;
522-
Session testSession = null;
523-
try {
524-
testSession = openSession();
520+
try ( Session testSession = openSession() ) {
525521
isolation = testSession.doReturningWork(
526-
new AbstractReturningWork<Integer>() {
522+
new AbstractReturningWork<>() {
527523
@Override
528524
public Integer execute(Connection connection) throws SQLException {
529525
return connection.getTransactionIsolation();
530526
}
531527
}
532528
);
533529
}
534-
catch( Throwable ignore ) {
535-
}
536-
finally {
537-
if ( testSession != null ) {
538-
try {
539-
testSession.close();
540-
}
541-
catch( Throwable ignore ) {
542-
}
543-
}
530+
catch (Throwable ignore) {
544531
}
545532
if ( isolation < Connection.TRANSACTION_READ_COMMITTED ) {
546533
SkipLog.reportSkip( "environment does not support at least read committed isolation", scenario );

0 commit comments

Comments
 (0)