Author: markt Date: Thu Jun 27 21:57:07 2013 New Revision: 1497579 URL: http://svn.apache.org/r1497579 Log: Refactor to remove duplicate code
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1497579&r1=1497578&r2=1497579&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Thu Jun 27 21:57:07 2013 @@ -151,6 +151,8 @@ public class WsServerContainer extends W SortedSet<TemplatePathMatch> templateMatches = configTemplateMatchMap.get(key); if (templateMatches == null) { + // Ensure that if concurrent threads execute this block they + // both end up using the same TreeSet instance templateMatches = new TreeSet<>( TemplatePathMatchComparator.getInstance()); configTemplateMatchMap.putIfAbsent(key, templateMatches); @@ -191,9 +193,6 @@ public class WsServerContainer extends W } String path = annotation.value(); - // Uri Template - UriTemplate uriTemplate = new UriTemplate(path); - // Validate encoders validateEncoders(annotation.encoders()); @@ -225,33 +224,7 @@ public class WsServerContainer extends W PojoEndpointServer.POJO_METHOD_MAPPING_KEY, methodMapping); - - if (uriTemplate.hasParameters()) { - Integer key = Integer.valueOf(uriTemplate.getSegmentCount()); - SortedSet<TemplatePathMatch> templateMatches = - configTemplateMatchMap.get(key); - if (templateMatches == null) { - // Ensure that if concurrent threads execute this block they - // both end up using the same TreeSet instance - templateMatches = new TreeSet<>( - TemplatePathMatchComparator.getInstance()); - configTemplateMatchMap.putIfAbsent(key, templateMatches); - templateMatches = configTemplateMatchMap.get(key); - } - if (!templateMatches.add(new TemplatePathMatch(sec, uriTemplate))) { - // Duplicate uriTemplate; - throw new DeploymentException( - sm.getString("serverContainer.duplicatePaths", path)); - } - } else { - // Exact match - ServerEndpointConfig old = configExactMatchMap.put(path, sec); - if (old != null) { - // Duplicate path mappings - throw new DeploymentException( - sm.getString("serverContainer.duplicatePaths", path)); - } - } + addEndpoint(sec); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org