Skip to content

Commit e6e110e

Browse files
committed
Remove warnings in BaseReactiveTest
Replace class casts with pattern variables
1 parent c964fa7 commit e6e110e

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/BaseReactiveTest.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,38 +293,32 @@ protected CompletionStage<Void> cleanDb() {
293293
}
294294

295295
protected static CompletionStage<Void> closeSession(Object closable) {
296-
if ( closable instanceof CompletionStage<?> ) {
297-
CompletionStage<?> closableStage = (CompletionStage<?>) closable;
296+
if ( closable instanceof CompletionStage<?> closableStage ) {
298297
return closableStage.thenCompose( BaseReactiveTest::closeSession );
299298
}
300-
if ( closable instanceof Uni<?> ) {
301-
Uni<?> closableUni = (Uni<?>) closable;
299+
if ( closable instanceof Uni<?> closableUni ) {
302300
return closableUni.subscribeAsCompletionStage()
303301
.thenCompose( BaseReactiveTest::closeSession );
304302
}
305-
if ( closable instanceof ReactiveConnection ) {
306-
return ( (ReactiveConnection) closable ).close();
303+
if ( closable instanceof ReactiveConnection reactiveConnection) {
304+
return reactiveConnection.close();
307305
}
308-
if ( closable instanceof Mutiny.Session ) {
309-
Mutiny.Session mutiny = (Mutiny.Session) closable;
306+
if ( closable instanceof Mutiny.Session mutiny ) {
310307
if ( mutiny.isOpen() ) {
311308
return mutiny.close().subscribeAsCompletionStage();
312309
}
313310
}
314-
if ( closable instanceof Stage.Session ) {
315-
Stage.Session stage = (Stage.Session) closable;
311+
if ( closable instanceof Stage.Session stage ) {
316312
if ( stage.isOpen() ) {
317313
return stage.close();
318314
}
319315
}
320-
if ( closable instanceof Mutiny.StatelessSession ) {
321-
Mutiny.StatelessSession mutiny = (Mutiny.StatelessSession) closable;
316+
if ( closable instanceof Mutiny.StatelessSession mutiny ) {
322317
if ( mutiny.isOpen() ) {
323318
return mutiny.close().subscribeAsCompletionStage();
324319
}
325320
}
326-
if ( closable instanceof Stage.StatelessSession ) {
327-
Stage.StatelessSession stage = (Stage.StatelessSession) closable;
321+
if ( closable instanceof Stage.StatelessSession stage ) {
328322
if ( stage.isOpen() ) {
329323
return stage.close();
330324
}

0 commit comments

Comments
 (0)