Polish contribution

See gh-31531
This commit is contained in:
Sam Brannen
2023-12-04 16:42:06 +01:00
parent 490b5c77fc
commit d71853f105
18 changed files with 55 additions and 51 deletions

View File

@@ -1656,20 +1656,20 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
// Invocation on ConnectionProxy interface coming in...
return switch (method.getName()) {
// Only consider equal when proxies are identical.
case "equals" -> (proxy == args[0]);
// Only consider equal when proxies are identical.
// Use hashCode of PersistenceManager proxy.
case "hashCode" -> System.identityHashCode(proxy);
// Use hashCode of PersistenceManager proxy.
// Handle close method: suppress, not valid.
case "close" -> null;
// Handle close method: suppress, not valid.
case "isClosed" -> false;
// Handle getTargetConnection method: return underlying Connection.
case "getTargetConnection" -> this.target;
// Handle getTargetConnection method: return underlying Connection.
case "unwrap" -> (((Class<?>) args[0]).isInstance(proxy) ? proxy : this.target.unwrap((Class<?>) args[0]));
case "isWrapperFor" -> (((Class<?>) args[0]).isInstance(proxy) || this.target.isWrapperFor((Class<?>) args[0]));
default -> {
// Invoke method on target Connection.
try {
// Invoke method on target Connection.
Object retVal = method.invoke(this.target, args);
// If return value is a JDBC Statement, apply statement settings

View File

@@ -350,20 +350,20 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
// Invocation on ConnectionProxy interface coming in...
return switch (method.getName()) {
// Only consider equal when proxies are identical.
case "equals" -> (proxy == args[0]);
// Only consider equal when proxies are identical.
// Use hashCode of Connection proxy.
case "hashCode" -> System.identityHashCode(proxy);
// Use hashCode of Connection proxy.
// Handle close method: don't pass the call on.
case "close" -> null;
// Handle close method: don't pass the call on.
case "isClosed" -> this.target.isClosed();
// Handle getTargetConnection method: return underlying Connection.
case "getTargetConnection" -> this.target;
// Handle getTargetConnection method: return underlying Connection.
case "unwrap" -> (((Class<?>) args[0]).isInstance(proxy) ? proxy : this.target.unwrap((Class<?>) args[0]));
case "isWrapperFor" -> (((Class<?>) args[0]).isInstance(proxy) || this.target.isWrapperFor((Class<?>) args[0]));
default -> {
// Invoke method on target Connection.
try {
// Invoke method on target Connection.
yield method.invoke(this.target, args);
}
catch (InvocationTargetException ex) {