Skip to content

Commit 568a5c8

Browse files
committed
Remove warnings in BaseReactiveTest
Replace class casts with pattern variables
1 parent b83b00e commit 568a5c8

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
@@ -308,38 +308,32 @@ protected CompletionStage<Void> cleanDb() {
308308
}
309309

310310
protected static CompletionStage<Void> closeSession(Object closable) {
311-
if ( closable instanceof CompletionStage<?> ) {
312-
CompletionStage<?> closableStage = (CompletionStage<?>) closable;
311+
if ( closable instanceof CompletionStage<?> closableStage ) {
313312
return closableStage.thenCompose( BaseReactiveTest::closeSession );
314313
}
315-
if ( closable instanceof Uni<?> ) {
316-
Uni<?> closableUni = (Uni<?>) closable;
314+
if ( closable instanceof Uni<?> closableUni ) {
317315
return closableUni.subscribeAsCompletionStage()
318316
.thenCompose( BaseReactiveTest::closeSession );
319317
}
320-
if ( closable instanceof ReactiveConnection ) {
321-
return ( (ReactiveConnection) closable ).close();
318+
if ( closable instanceof ReactiveConnection reactiveConnection) {
319+
return reactiveConnection.close();
322320
}
323-
if ( closable instanceof Mutiny.Session ) {
324-
Mutiny.Session mutiny = (Mutiny.Session) closable;
321+
if ( closable instanceof Mutiny.Session mutiny ) {
325322
if ( mutiny.isOpen() ) {
326323
return mutiny.close().subscribeAsCompletionStage();
327324
}
328325
}
329-
if ( closable instanceof Stage.Session ) {
330-
Stage.Session stage = (Stage.Session) closable;
326+
if ( closable instanceof Stage.Session stage ) {
331327
if ( stage.isOpen() ) {
332328
return stage.close();
333329
}
334330
}
335-
if ( closable instanceof Mutiny.StatelessSession ) {
336-
Mutiny.StatelessSession mutiny = (Mutiny.StatelessSession) closable;
331+
if ( closable instanceof Mutiny.StatelessSession mutiny ) {
337332
if ( mutiny.isOpen() ) {
338333
return mutiny.close().subscribeAsCompletionStage();
339334
}
340335
}
341-
if ( closable instanceof Stage.StatelessSession ) {
342-
Stage.StatelessSession stage = (Stage.StatelessSession) closable;
336+
if ( closable instanceof Stage.StatelessSession stage ) {
343337
if ( stage.isOpen() ) {
344338
return stage.close();
345339
}

0 commit comments

Comments
 (0)