diff --git a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java b/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java index ceca9d8094e..416d8a39099 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java @@ -280,7 +280,6 @@ public class InvocableHandlerMethod extends HandlerMethod { /** * Invoke the given Kotlin coroutine suspended function. - * *
The default implementation invokes * {@link CoroutinesUtils#invokeSuspendingFunction(Method, Object, Object...)}, * but subclasses can override this method to use @@ -292,6 +291,7 @@ public class InvocableHandlerMethod extends HandlerMethod { return CoroutinesUtils.invokeSuspendingFunction(method, target, args); } + /** * Inner class to avoid a hard dependency on Kotlin at runtime. */ @@ -334,7 +334,6 @@ public class InvocableHandlerMethod extends HandlerMethod { Object result = function.callBy(argMap); return (result == Unit.INSTANCE ? null : result); } - } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java index 0dbc0f69977..63f22259942 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java @@ -313,6 +313,7 @@ public class InvocableHandlerMethod extends HandlerMethod { return false; } + /** * Inner class to avoid a hard dependency on Kotlin at runtime. */ @@ -371,7 +372,6 @@ public class InvocableHandlerMethod extends HandlerMethod { return (result == Unit.INSTANCE ? null : result); } } - } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java index 158db36802f..30ddf9cd086 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -248,30 +248,31 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat @Override public void close(CloseStatus status) throws IOException { - this.closeLock.lock(); - try { - if (this.closeInProgress) { - return; - } - if (!CloseStatus.SESSION_NOT_RELIABLE.equals(status)) { - try { - checkSessionLimits(); - } - catch (SessionLimitExceededException ex) { - // Ignore + if (this.closeLock.tryLock()) { + try { + if (this.closeInProgress) { + return; } - if (this.limitExceeded) { - if (logger.isDebugEnabled()) { - logger.debug("Changing close status " + status + " to SESSION_NOT_RELIABLE."); + if (!CloseStatus.SESSION_NOT_RELIABLE.equals(status)) { + try { + checkSessionLimits(); + } + catch (SessionLimitExceededException ex) { + // Ignore + } + if (this.limitExceeded) { + if (logger.isDebugEnabled()) { + logger.debug("Changing close status " + status + " to SESSION_NOT_RELIABLE."); + } + status = CloseStatus.SESSION_NOT_RELIABLE; } - status = CloseStatus.SESSION_NOT_RELIABLE; } + this.closeInProgress = true; + super.close(status); + } + finally { + this.closeLock.unlock(); } - this.closeInProgress = true; - super.close(status); - } - finally { - this.closeLock.unlock(); } }