Revert use of yield in switch expressions due to Eclipse compiler error
See gh-31531
This commit is contained in:
parent
d71853f105
commit
b69e5acfe3
|
|
@ -600,27 +600,31 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
@Override
|
@Override
|
||||||
@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()) {
|
switch (method.getName()) {
|
||||||
case "equals" -> {
|
case "equals" -> {
|
||||||
Object other = args[0];
|
Object other = args[0];
|
||||||
if (proxy == other) {
|
if (proxy == other) {
|
||||||
yield true;
|
return true;
|
||||||
}
|
}
|
||||||
if (other == null || !Proxy.isProxyClass(other.getClass())) {
|
if (other == null || !Proxy.isProxyClass(other.getClass())) {
|
||||||
yield false;
|
return false;
|
||||||
}
|
}
|
||||||
InvocationHandler otherHandler = Proxy.getInvocationHandler(other);
|
InvocationHandler otherHandler = Proxy.getInvocationHandler(other);
|
||||||
yield (otherHandler instanceof SharedConnectionInvocationHandler sharedHandler &&
|
return (otherHandler instanceof SharedConnectionInvocationHandler sharedHandler &&
|
||||||
factory() == sharedHandler.factory());
|
factory() == sharedHandler.factory());
|
||||||
}
|
}
|
||||||
case "hashCode" -> System.identityHashCode(factory());
|
case "hashCode" -> {
|
||||||
// Use hashCode of containing SingleConnectionFactory.
|
// Use hashCode of containing SingleConnectionFactory.
|
||||||
case "toString" -> "Shared JMS Connection: " + getConnection();
|
return System.identityHashCode(factory());
|
||||||
|
}
|
||||||
|
case "toString" -> {
|
||||||
|
return "Shared JMS Connection: " + getConnection();
|
||||||
|
}
|
||||||
case "setClientID" -> {
|
case "setClientID" -> {
|
||||||
// Handle setClientID method: throw exception if not compatible.
|
// Handle setClientID method: throw exception if not compatible.
|
||||||
String currentClientId = getConnection().getClientID();
|
String currentClientId = getConnection().getClientID();
|
||||||
if (currentClientId != null && currentClientId.equals(args[0])) {
|
if (currentClientId != null && currentClientId.equals(args[0])) {
|
||||||
yield null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new jakarta.jms.IllegalStateException(
|
throw new jakarta.jms.IllegalStateException(
|
||||||
|
|
@ -642,7 +646,7 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
}
|
}
|
||||||
this.localExceptionListener = listener;
|
this.localExceptionListener = listener;
|
||||||
}
|
}
|
||||||
yield null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new jakarta.jms.IllegalStateException(
|
throw new jakarta.jms.IllegalStateException(
|
||||||
|
|
@ -656,20 +660,20 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
case "getExceptionListener" -> {
|
case "getExceptionListener" -> {
|
||||||
synchronized (connectionMonitor) {
|
synchronized (connectionMonitor) {
|
||||||
if (this.localExceptionListener != null) {
|
if (this.localExceptionListener != null) {
|
||||||
yield this.localExceptionListener;
|
return this.localExceptionListener;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield getExceptionListener();
|
return getExceptionListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "start" -> {
|
case "start" -> {
|
||||||
localStart();
|
localStart();
|
||||||
yield null;
|
return null;
|
||||||
}
|
}
|
||||||
case "stop" -> {
|
case "stop" -> {
|
||||||
localStop();
|
localStop();
|
||||||
yield null;
|
return null;
|
||||||
}
|
}
|
||||||
case "close" -> {
|
case "close" -> {
|
||||||
localStop();
|
localStop();
|
||||||
|
|
@ -681,7 +685,7 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
this.localExceptionListener = null;
|
this.localExceptionListener = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yield null;
|
return null;
|
||||||
}
|
}
|
||||||
case "createSession", "createQueueSession", "createTopicSession" -> {
|
case "createSession", "createQueueSession", "createTopicSession" -> {
|
||||||
// Default: JMS 2.0 createSession() method
|
// Default: JMS 2.0 createSession() method
|
||||||
|
|
@ -710,25 +714,17 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||||
}
|
}
|
||||||
throw new jakarta.jms.IllegalStateException(msg);
|
throw new jakarta.jms.IllegalStateException(msg);
|
||||||
}
|
}
|
||||||
yield session;
|
return session;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
yield method.invoke(getConnection(), args);
|
return method.invoke(getConnection(), args);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
throw ex.getTargetException();
|
throw ex.getTargetException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default -> {
|
|
||||||
try {
|
|
||||||
yield method.invoke(getConnection(), args);
|
|
||||||
}
|
|
||||||
catch (InvocationTargetException ex) {
|
|
||||||
throw ex.getTargetException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void localStart() throws JMSException {
|
private void localStart() throws JMSException {
|
||||||
synchronized (connectionMonitor) {
|
synchronized (connectionMonitor) {
|
||||||
|
|
|
||||||
|
|
@ -720,20 +720,26 @@ public class MvcUriComponentsBuilder {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object intercept(@Nullable Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
|
public Object intercept(@Nullable Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
|
||||||
return switch (method.getName()) {
|
switch (method.getName()) {
|
||||||
case "getControllerType" -> this.controllerType;
|
case "getControllerType" -> {
|
||||||
case "getControllerMethod" -> this.controllerMethod;
|
return this.controllerType;
|
||||||
case "getArgumentValues" -> this.argumentValues;
|
}
|
||||||
|
case "getControllerMethod" -> {
|
||||||
|
return this.controllerMethod;
|
||||||
|
}
|
||||||
|
case "getArgumentValues" -> {
|
||||||
|
return this.argumentValues;
|
||||||
|
}
|
||||||
default -> {
|
default -> {
|
||||||
if (ReflectionUtils.isObjectMethod(method)) {
|
if (ReflectionUtils.isObjectMethod(method)) {
|
||||||
yield ReflectionUtils.invokeMethod(method, obj, args);
|
return ReflectionUtils.invokeMethod(method, obj, args);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.controllerMethod = method;
|
this.controllerMethod = method;
|
||||||
this.argumentValues = args;
|
this.argumentValues = args;
|
||||||
Class<?> returnType = method.getReturnType();
|
Class<?> returnType = method.getReturnType();
|
||||||
try {
|
try {
|
||||||
yield (returnType == void.class ? null : returnType.cast(initProxy(returnType, this)));
|
return (returnType == void.class ? null : returnType.cast(initProxy(returnType, this)));
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|
@ -741,7 +747,7 @@ public class MvcUriComponentsBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue