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

@@ -252,16 +252,16 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory
@Nullable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
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.
case "unwrap" -> this.target;
// Handle close method: suppress, not valid.
case "close" -> Mono.empty();
// Handle close method: suppress, not valid.
default -> {
// Invoke method on target Connection.
try {
// Invoke method on target Connection.
yield method.invoke(this.target, args);
}
catch (InvocationTargetException ex) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -145,17 +145,17 @@ public class TransactionAwareConnectionFactoryProxy extends DelegatingConnection
return switch (method.getName()) {
case "unwrap" -> this.connection;
// Handle close method: only close if not within a transaction.
case "close" -> ConnectionFactoryUtils.doReleaseConnection(this.connection, this.targetConnectionFactory)
.doOnSubscribe(n -> this.closed = true);
// Handle close method: only close if not within a transaction.
case "isClosed" -> this.closed;
default -> {
if (this.closed) {
throw new IllegalStateException("Connection handle already closed");
}
// Invoke method on target Connection.
try {
// Invoke method on target Connection.
yield method.invoke(this.connection, args);
}
catch (InvocationTargetException ex) {
@@ -167,7 +167,7 @@ public class TransactionAwareConnectionFactoryProxy extends DelegatingConnection
private String proxyToString(@Nullable Object proxy) {
// Allow for differentiating between the proxy and the raw Connection.
return "Transaction-aware proxy for target Connection [" + this.connection.toString() + "]";
return "Transaction-aware proxy for target Connection [" + this.connection + "]";
}
}

View File

@@ -520,16 +520,16 @@ final class DefaultDatabaseClient implements DatabaseClient {
@Nullable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
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.
case "unwrap" -> this.target;
// Handle close method: suppress, not valid.
case "close" -> Mono.error(new UnsupportedOperationException("Close is not supported!"));
// Handle close method: suppress, not valid.
default -> {
// Invoke method on target Connection.
try {
// Invoke method on target Connection.
yield method.invoke(this.target, args);
}
catch (InvocationTargetException ex) {