Skip to content

Commit 53f4912

Browse files
committed
Use enhanced switch statements where appropriate
1 parent a193fc3 commit 53f4912

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,6 +73,7 @@
7373
* {@link java.sql.Connection#unwrap(Class)}.
7474
*
7575
* @author Thomas Risberg
76+
* @author Mahmoud Ben Hassine
7677
* @see #getConnection()
7778
* @see java.sql.Connection#close()
7879
* @see DataSourceUtils#releaseConnection
@@ -252,13 +253,15 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
252253
// Invocation on ConnectionProxy interface coming in...
253254

254255
switch (method.getName()) {
255-
case "equals":
256+
case "equals" -> {
256257
// Only consider equal when proxies are identical.
257258
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
258-
case "hashCode":
259+
}
260+
case "hashCode" -> {
259261
// Use hashCode of Connection proxy.
260262
return System.identityHashCode(proxy);
261-
case "close":
263+
}
264+
case "close" -> {
262265
// Handle close method: don't pass the call on if we are
263266
// suppressing close calls.
264267
if (dataSource.completeCloseCall((Connection) proxy)) {
@@ -268,10 +271,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
268271
target.close();
269272
return null;
270273
}
271-
case "getTargetConnection":
274+
}
275+
case "getTargetConnection" -> {
272276
// Handle getTargetConnection method: return underlying
273277
// Connection.
274278
return this.target;
279+
}
275280
}
276281

277282
// Invoke method on target Connection.

0 commit comments

Comments
 (0)