You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/03/06 09:33:36 UTC
[19/19] git commit: Improve usage of concurrent map - no need of
synchronization.
Improve usage of concurrent map - no need of synchronization.
Add javadoc
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e059351f
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e059351f
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e059351f
Branch: refs/heads/master
Commit: e059351fb80cf3fadd446f6c73240396f577e0c5
Parents: 900d5a8
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu Mar 6 10:28:41 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Thu Mar 6 10:28:41 2014 +0200
----------------------------------------------------------------------
.../registry/SimpleWebSocketConnectionRegistry.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/e059351f/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/registry/SimpleWebSocketConnectionRegistry.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/registry/SimpleWebSocketConnectionRegistry.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/registry/SimpleWebSocketConnectionRegistry.java
index 8e6d46d..7ead116 100644
--- a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/registry/SimpleWebSocketConnectionRegistry.java
+++ b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/registry/SimpleWebSocketConnectionRegistry.java
@@ -65,7 +65,8 @@ public class SimpleWebSocketConnectionRegistry implements IWebSocketConnectionRe
* Returns a collection of currently active websockets. The connections might close at any time.
*
* @param application
- * @return
+ * The application
+ * @return a collection of currently active websockets
*/
public Collection<IWebSocketConnection> getConnections(Application application)
{
@@ -107,13 +108,14 @@ public class SimpleWebSocketConnectionRegistry implements IWebSocketConnectionRe
ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
if (connectionsByPage == null && connection != null)
{
- synchronized (connectionsBySession)
+ connectionsByPage = connectionsBySession.get(sessionId);
+ if (connectionsByPage == null)
{
- connectionsByPage = connectionsBySession.get(sessionId);
- if (connectionsByPage == null)
+ connectionsByPage = Generics.newConcurrentHashMap();
+ ConcurrentMap<IKey, IWebSocketConnection> old = connectionsBySession.putIfAbsent(sessionId, connectionsByPage);
+ if (old != null)
{
- connectionsByPage = Generics.newConcurrentHashMap();
- connectionsBySession.put(sessionId, connectionsByPage);
+ connectionsByPage = old;
}
}
}