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

@ -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.

View File

@ -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");
* you may not use this file except in compliance with the License.

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.

View File

@ -269,7 +269,7 @@ public class DateFormatter implements Formatter<Date> {
if (timeStyle != -1) {
return DateFormat.getTimeInstance(timeStyle, locale);
}
throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'");
throw unsupportedStylePatternException();
}
return DateFormat.getDateInstance(this.style, locale);
@ -284,10 +284,14 @@ public class DateFormatter implements Formatter<Date> {
case 'L' -> DateFormat.LONG;
case 'F' -> DateFormat.FULL;
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 + "'");
}
}

View File

@ -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");
* you may not use this file except in compliance with the License.

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) {

View File

@ -625,7 +625,7 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
else {
throw new jakarta.jms.IllegalStateException(
"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" -> {
@ -647,9 +647,9 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
else {
throw new jakarta.jms.IllegalStateException(
"setExceptionListener call not supported on proxy for shared Connection. " +
"Set the 'exceptionListener' property on the SingleConnectionFactory instead. " +
"Alternatively, activate SingleConnectionFactory's 'reconnectOnException' feature, " +
"which will allow for registering further ExceptionListeners to the recovery chain.");
"Set the 'exceptionListener' property on the SingleConnectionFactory instead. " +
"Alternatively, activate SingleConnectionFactory's 'reconnectOnException' feature, " +
"which will allow for registering further ExceptionListeners to the recovery chain.");
}
}
}

View File

@ -332,21 +332,21 @@ public class TransactionAwareConnectionFactoryProxy
// Invocation on SessionProxy 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.
case "commit" ->
throw new TransactionInProgressException("Commit call not allowed within a managed transaction");
case "rollback" ->
throw new TransactionInProgressException("Rollback call not allowed within a managed transaction");
// Handle close method: not to be closed within a transaction.
case "close" -> null;
// Handle close method: not to be closed within a transaction.
// Handle getTargetSession method: return underlying Session.
case "getTargetSession" -> this.target;
// Handle getTargetSession method: return underlying Session.
default -> {
// Invoke method on target Session.
try {
// Invoke method on target Session.
yield method.invoke(this.target, args);
}
catch (InvocationTargetException ex) {

View File

@ -1151,15 +1151,15 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
// Invocation on Session 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 Session proxy.
case "hashCode" -> System.identityHashCode(proxy);
// Use hashCode of Session proxy.
// Handle close method: suppress, not valid.
case "close" -> null;
// Handle close method: suppress, not valid.
default -> {
// Invoke method on target Session.
try {
// Invoke method on target Session.
Object retVal = method.invoke(this.target, args);
// If return value is a Query or Criteria, apply transaction timeout.

View File

@ -413,17 +413,17 @@ public class LocalSessionFactoryBuilder extends Configuration {
@Override
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 EntityManagerFactory proxy.
case "hashCode" -> System.identityHashCode(proxy);
// Use hashCode of EntityManagerFactory proxy.
case "getProperties" -> getProperties();
// Call coming in through InfrastructureProxy interface...
case "getWrappedObject" -> getSessionFactory();
// Call coming in through InfrastructureProxy interface...
default -> {
// Regular delegation to the target SessionFactory,
// enforcing its full initialization...
try {
// Regular delegation to the target SessionFactory,
// enforcing its full initialization...
yield method.invoke(getSessionFactory(), args);
}
catch (InvocationTargetException ex) {

View File

@ -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");
* you may not use this file except in compliance with the License.

View File

@ -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");
* you may not use this file except in compliance with the License.

View File

@ -264,7 +264,7 @@ public abstract class SharedEntityManagerCreator {
case "getTransaction" -> {
throw new IllegalStateException(
"Not allowed to create transaction on shared EntityManager - " +
"use Spring transactions or EJB CMT instead");
"use Spring transactions or EJB CMT instead");
}
}

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) {

View File

@ -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");
* you may not use this file except in compliance with the License.