parent
490b5c77fc
commit
d71853f105
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -269,7 +269,7 @@ public class DateFormatter implements Formatter<Date> {
|
||||||
if (timeStyle != -1) {
|
if (timeStyle != -1) {
|
||||||
return DateFormat.getTimeInstance(timeStyle, locale);
|
return DateFormat.getTimeInstance(timeStyle, locale);
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'");
|
throw unsupportedStylePatternException();
|
||||||
|
|
||||||
}
|
}
|
||||||
return DateFormat.getDateInstance(this.style, locale);
|
return DateFormat.getDateInstance(this.style, locale);
|
||||||
|
@ -284,10 +284,14 @@ public class DateFormatter implements Formatter<Date> {
|
||||||
case 'L' -> DateFormat.LONG;
|
case 'L' -> DateFormat.LONG;
|
||||||
case 'F' -> DateFormat.FULL;
|
case 'F' -> DateFormat.FULL;
|
||||||
case '-' -> -1;
|
case '-' -> -1;
|
||||||
default -> throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'");
|
default -> throw unsupportedStylePatternException();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'");
|
throw unsupportedStylePatternException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IllegalStateException unsupportedStylePatternException() {
|
||||||
|
return new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1656,20 +1656,20 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||||
// Invocation on ConnectionProxy interface coming in...
|
// Invocation on ConnectionProxy interface coming in...
|
||||||
|
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> (proxy == args[0]);
|
case "equals" -> (proxy == args[0]);
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of PersistenceManager proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of PersistenceManager proxy.
|
// Handle close method: suppress, not valid.
|
||||||
case "close" -> null;
|
case "close" -> null;
|
||||||
// Handle close method: suppress, not valid.
|
|
||||||
case "isClosed" -> false;
|
case "isClosed" -> false;
|
||||||
|
// Handle getTargetConnection method: return underlying Connection.
|
||||||
case "getTargetConnection" -> this.target;
|
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 "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]));
|
case "isWrapperFor" -> (((Class<?>) args[0]).isInstance(proxy) || this.target.isWrapperFor((Class<?>) args[0]));
|
||||||
default -> {
|
default -> {
|
||||||
// Invoke method on target Connection.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Connection.
|
||||||
Object retVal = method.invoke(this.target, args);
|
Object retVal = method.invoke(this.target, args);
|
||||||
|
|
||||||
// If return value is a JDBC Statement, apply statement settings
|
// If return value is a JDBC Statement, apply statement settings
|
||||||
|
|
|
@ -350,20 +350,20 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
|
||||||
// Invocation on ConnectionProxy interface coming in...
|
// Invocation on ConnectionProxy interface coming in...
|
||||||
|
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> (proxy == args[0]);
|
case "equals" -> (proxy == args[0]);
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of Connection proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of Connection proxy.
|
// Handle close method: don't pass the call on.
|
||||||
case "close" -> null;
|
case "close" -> null;
|
||||||
// Handle close method: don't pass the call on.
|
|
||||||
case "isClosed" -> this.target.isClosed();
|
case "isClosed" -> this.target.isClosed();
|
||||||
|
// Handle getTargetConnection method: return underlying Connection.
|
||||||
case "getTargetConnection" -> this.target;
|
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 "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]));
|
case "isWrapperFor" -> (((Class<?>) args[0]).isInstance(proxy) || this.target.isWrapperFor((Class<?>) args[0]));
|
||||||
default -> {
|
default -> {
|
||||||
// Invoke method on target Connection.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Connection.
|
||||||
yield method.invoke(this.target, args);
|
yield method.invoke(this.target, args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
|
|
|
@ -625,7 +625,7 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
else {
|
else {
|
||||||
throw new jakarta.jms.IllegalStateException(
|
throw new jakarta.jms.IllegalStateException(
|
||||||
"setClientID call not supported on proxy for shared Connection. " +
|
"setClientID call not supported on proxy for shared Connection. " +
|
||||||
"Set the 'clientId' property on the SingleConnectionFactory instead.");
|
"Set the 'clientId' property on the SingleConnectionFactory instead.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "setExceptionListener" -> {
|
case "setExceptionListener" -> {
|
||||||
|
@ -647,9 +647,9 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
else {
|
else {
|
||||||
throw new jakarta.jms.IllegalStateException(
|
throw new jakarta.jms.IllegalStateException(
|
||||||
"setExceptionListener call not supported on proxy for shared Connection. " +
|
"setExceptionListener call not supported on proxy for shared Connection. " +
|
||||||
"Set the 'exceptionListener' property on the SingleConnectionFactory instead. " +
|
"Set the 'exceptionListener' property on the SingleConnectionFactory instead. " +
|
||||||
"Alternatively, activate SingleConnectionFactory's 'reconnectOnException' feature, " +
|
"Alternatively, activate SingleConnectionFactory's 'reconnectOnException' feature, " +
|
||||||
"which will allow for registering further ExceptionListeners to the recovery chain.");
|
"which will allow for registering further ExceptionListeners to the recovery chain.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,21 +332,21 @@ public class TransactionAwareConnectionFactoryProxy
|
||||||
// Invocation on SessionProxy interface coming in...
|
// Invocation on SessionProxy interface coming in...
|
||||||
|
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> (proxy == args[0]);
|
case "equals" -> (proxy == args[0]);
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of Connection proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of Connection proxy.
|
|
||||||
case "commit" ->
|
case "commit" ->
|
||||||
throw new TransactionInProgressException("Commit call not allowed within a managed transaction");
|
throw new TransactionInProgressException("Commit call not allowed within a managed transaction");
|
||||||
case "rollback" ->
|
case "rollback" ->
|
||||||
throw new TransactionInProgressException("Rollback call not allowed within a managed transaction");
|
throw new TransactionInProgressException("Rollback call not allowed within a managed transaction");
|
||||||
|
// Handle close method: not to be closed within a transaction.
|
||||||
case "close" -> null;
|
case "close" -> null;
|
||||||
// Handle close method: not to be closed within a transaction.
|
// Handle getTargetSession method: return underlying Session.
|
||||||
case "getTargetSession" -> this.target;
|
case "getTargetSession" -> this.target;
|
||||||
// Handle getTargetSession method: return underlying Session.
|
|
||||||
default -> {
|
default -> {
|
||||||
// Invoke method on target Session.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Session.
|
||||||
yield method.invoke(this.target, args);
|
yield method.invoke(this.target, args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
|
|
|
@ -1151,15 +1151,15 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||||
// Invocation on Session interface coming in...
|
// Invocation on Session interface coming in...
|
||||||
|
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> (proxy == args[0]);
|
case "equals" -> (proxy == args[0]);
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of Session proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of Session proxy.
|
// Handle close method: suppress, not valid.
|
||||||
case "close" -> null;
|
case "close" -> null;
|
||||||
// Handle close method: suppress, not valid.
|
|
||||||
default -> {
|
default -> {
|
||||||
// Invoke method on target Session.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Session.
|
||||||
Object retVal = method.invoke(this.target, args);
|
Object retVal = method.invoke(this.target, args);
|
||||||
|
|
||||||
// If return value is a Query or Criteria, apply transaction timeout.
|
// If return value is a Query or Criteria, apply transaction timeout.
|
||||||
|
|
|
@ -413,17 +413,17 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> (proxy == args[0]);
|
case "equals" -> (proxy == args[0]);
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of EntityManagerFactory proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of EntityManagerFactory proxy.
|
|
||||||
case "getProperties" -> getProperties();
|
case "getProperties" -> getProperties();
|
||||||
|
// Call coming in through InfrastructureProxy interface...
|
||||||
case "getWrappedObject" -> getSessionFactory();
|
case "getWrappedObject" -> getSessionFactory();
|
||||||
// Call coming in through InfrastructureProxy interface...
|
|
||||||
default -> {
|
default -> {
|
||||||
// Regular delegation to the target SessionFactory,
|
|
||||||
// enforcing its full initialization...
|
|
||||||
try {
|
try {
|
||||||
|
// Regular delegation to the target SessionFactory,
|
||||||
|
// enforcing its full initialization...
|
||||||
yield method.invoke(getSessionFactory(), args);
|
yield method.invoke(getSessionFactory(), args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -264,7 +264,7 @@ public abstract class SharedEntityManagerCreator {
|
||||||
case "getTransaction" -> {
|
case "getTransaction" -> {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Not allowed to create transaction on shared EntityManager - " +
|
"Not allowed to create transaction on shared EntityManager - " +
|
||||||
"use Spring transactions or EJB CMT instead");
|
"use Spring transactions or EJB CMT instead");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,16 +252,16 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> proxy == args[0];
|
case "equals" -> proxy == args[0];
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of PersistenceManager proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of PersistenceManager proxy.
|
|
||||||
case "unwrap" -> this.target;
|
case "unwrap" -> this.target;
|
||||||
|
// Handle close method: suppress, not valid.
|
||||||
case "close" -> Mono.empty();
|
case "close" -> Mono.empty();
|
||||||
// Handle close method: suppress, not valid.
|
|
||||||
default -> {
|
default -> {
|
||||||
// Invoke method on target Connection.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Connection.
|
||||||
yield method.invoke(this.target, args);
|
yield method.invoke(this.target, args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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()) {
|
return switch (method.getName()) {
|
||||||
case "unwrap" -> this.connection;
|
case "unwrap" -> this.connection;
|
||||||
|
// Handle close method: only close if not within a transaction.
|
||||||
case "close" -> ConnectionFactoryUtils.doReleaseConnection(this.connection, this.targetConnectionFactory)
|
case "close" -> ConnectionFactoryUtils.doReleaseConnection(this.connection, this.targetConnectionFactory)
|
||||||
.doOnSubscribe(n -> this.closed = true);
|
.doOnSubscribe(n -> this.closed = true);
|
||||||
// Handle close method: only close if not within a transaction.
|
|
||||||
case "isClosed" -> this.closed;
|
case "isClosed" -> this.closed;
|
||||||
default -> {
|
default -> {
|
||||||
if (this.closed) {
|
if (this.closed) {
|
||||||
throw new IllegalStateException("Connection handle already closed");
|
throw new IllegalStateException("Connection handle already closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke method on target Connection.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Connection.
|
||||||
yield method.invoke(this.connection, args);
|
yield method.invoke(this.connection, args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
|
@ -167,7 +167,7 @@ public class TransactionAwareConnectionFactoryProxy extends DelegatingConnection
|
||||||
|
|
||||||
private String proxyToString(@Nullable Object proxy) {
|
private String proxyToString(@Nullable Object proxy) {
|
||||||
// Allow for differentiating between the proxy and the raw Connection.
|
// 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 + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,16 +520,16 @@ final class DefaultDatabaseClient implements DatabaseClient {
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
return switch (method.getName()) {
|
return switch (method.getName()) {
|
||||||
|
// Only consider equal when proxies are identical.
|
||||||
case "equals" -> proxy == args[0];
|
case "equals" -> proxy == args[0];
|
||||||
// Only consider equal when proxies are identical.
|
// Use hashCode of PersistenceManager proxy.
|
||||||
case "hashCode" -> System.identityHashCode(proxy);
|
case "hashCode" -> System.identityHashCode(proxy);
|
||||||
// Use hashCode of PersistenceManager proxy.
|
|
||||||
case "unwrap" -> this.target;
|
case "unwrap" -> this.target;
|
||||||
|
// Handle close method: suppress, not valid.
|
||||||
case "close" -> Mono.error(new UnsupportedOperationException("Close is not supported!"));
|
case "close" -> Mono.error(new UnsupportedOperationException("Close is not supported!"));
|
||||||
// Handle close method: suppress, not valid.
|
|
||||||
default -> {
|
default -> {
|
||||||
// Invoke method on target Connection.
|
|
||||||
try {
|
try {
|
||||||
|
// Invoke method on target Connection.
|
||||||
yield method.invoke(this.target, args);
|
yield method.invoke(this.target, args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
Loading…
Reference in New Issue