You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by th...@apache.org on 2022/04/04 17:07:55 UTC

[wicket] branch wicket-8.x updated: WICKET-6965 Store application name to avoid accessing the session during `onClose` and `onError` (#507)

This is an automated email from the ASF dual-hosted git repository.

theigl pushed a commit to branch wicket-8.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-8.x by this push:
     new a557238215 WICKET-6965 Store application name to avoid accessing the session during `onClose` and `onError` (#507)
a557238215 is described below

commit a557238215b0c0652e13d53ae0df7502c6008acc
Author: Thomas Heigl <th...@gmail.com>
AuthorDate: Mon Apr 4 18:54:07 2022 +0200

    WICKET-6965 Store application name to avoid accessing the session during `onClose` and `onError` (#507)
    
    (cherry picked from commit 243f6ffd0124263e5d527a24758c8ab3f76acdfa)
---
 .../org/apache/wicket/protocol/ws/javax/WicketEndpoint.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java b/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java
index cf9c6dea85..246a59c10a 100644
--- a/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java
+++ b/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java
@@ -54,15 +54,16 @@ public class WicketEndpoint extends Endpoint
 	 */
 	private static final String WICKET_APP_PARAM_NAME = "wicket-app-name";
 
+	private String applicationName;
 	private JavaxWebSocketProcessor javaxWebSocketProcessor;
 
 	@Override
 	public void onOpen(Session session, EndpointConfig endpointConfig)
 	{
-		String appName = getApplicationName(session);
+		applicationName = getApplicationName(session);
 
-		WebApplication app = (WebApplication) WebApplication.get(appName);
-		if (RUNNING_APPLICATIONS.add(appName))
+		WebApplication app = (WebApplication)WebApplication.get(applicationName);
+		if (RUNNING_APPLICATIONS.add(applicationName))
 		{
 			app.getApplicationListeners().add(new ApplicationListener());
 		}
@@ -89,8 +90,7 @@ public class WicketEndpoint extends Endpoint
 		LOG.debug("Web Socket connection with id '{}' has been closed with code '{}' and reason: {}",
 				session.getId(), closeCode, reasonPhrase);
 
-		String applicationName = getApplicationName(session);
-		if (isApplicationAlive(applicationName) && javaxWebSocketProcessor != null)
+		if (javaxWebSocketProcessor != null && isApplicationAlive(applicationName))
 		{
 			javaxWebSocketProcessor.onClose(closeCode, reasonPhrase);
 		}
@@ -110,8 +110,7 @@ public class WicketEndpoint extends Endpoint
 
 		super.onError(session, t);
 
-		String applicationName = getApplicationName(session);
-		if (isApplicationAlive(applicationName) && javaxWebSocketProcessor != null)
+		if (javaxWebSocketProcessor != null && isApplicationAlive(applicationName))
 		{
 			javaxWebSocketProcessor.onError(t);
 		}