From 7cb553557efcf08bc6d487aa15e051bdbd67610b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 4 Oct 2013 14:00:58 +1000 Subject: [PATCH] 418636 Name anonymous filter and holders with classname-hashcode Conflicts: jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java --- .../src/main/java/org/eclipse/jetty/servlet/Holder.java | 4 +++- .../java/org/eclipse/jetty/servlet/ServletHandler.java | 3 --- .../java/org/eclipse/jetty/servlet/ServletHolder.java | 2 -- .../java/org/eclipse/jetty/servlet/ErrorPageTest.java | 8 ++++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Holder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Holder.java index a7778a974ad..0c2be5991b3 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Holder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Holder.java @@ -216,6 +216,8 @@ public class Holder extends AbstractLifeCycle implements Dumpable { _className = className; _class=null; + if (_name==null) + _name=className+"-"+Integer.toHexString(this.hashCode()); } /* ------------------------------------------------------------ */ @@ -229,7 +231,7 @@ public class Holder extends AbstractLifeCycle implements Dumpable { _className=held.getName(); if (_name==null) - _name=held.getName()+"-"+this.hashCode(); + _name=held.getName()+"-"+Integer.toHexString(this.hashCode()); } } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java index beb7bcbb357..1470d34bd93 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java @@ -843,7 +843,6 @@ public class ServletHandler extends ScopedHandler public ServletHolder addServletWithMapping (String className,String pathSpec) { ServletHolder holder = newServletHolder(Holder.Source.EMBEDDED); - holder.setName(className+"-"+(_servlets==null?0:_servlets.length)); holder.setClassName(className); addServletWithMapping(holder,pathSpec); return holder; @@ -956,7 +955,6 @@ public class ServletHandler extends ScopedHandler public FilterHolder addFilterWithMapping (String className,String pathSpec,EnumSet dispatches) { FilterHolder holder = newFilterHolder(Holder.Source.EMBEDDED); - holder.setName(className+"-"+_filters.length); holder.setClassName(className); addFilterWithMapping(holder,pathSpec,dispatches); @@ -1025,7 +1023,6 @@ public class ServletHandler extends ScopedHandler public FilterHolder addFilterWithMapping (String className,String pathSpec,int dispatches) { FilterHolder holder = newFilterHolder(Holder.Source.EMBEDDED); - holder.setName(className+"-"+_filters.length); holder.setClassName(className); addFilterWithMapping(holder,pathSpec,dispatches); diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index 3a13a3f813c..86a4a0ee534 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -199,8 +199,6 @@ public class ServletHolder extends Holder implements UserIdentity.Scope int c=(_className!=null && sh._className!=null)?_className.compareTo(sh._className):0; if (c==0) c=_name.compareTo(sh._name); - if (c==0) - c=this.hashCode()>sh.hashCode()?1:-1; return c; } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java index f0759a7b336..ba13937acd1 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java @@ -91,7 +91,7 @@ public class ErrorPageTest assertThat(response,Matchers.containsString("ERROR_CODE: 599")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION: null")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION_TYPE: null")); - assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-1")); + assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-")); assertThat(response,Matchers.containsString("ERROR_REQUEST_URI: /fail/code")); } @@ -104,7 +104,7 @@ public class ErrorPageTest assertThat(response,Matchers.containsString("ERROR_CODE: 500")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION: java.lang.IllegalStateException")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION_TYPE: class java.lang.IllegalStateException")); - assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-1")); + assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-")); assertThat(response,Matchers.containsString("ERROR_REQUEST_URI: /fail/exception")); } @@ -117,7 +117,7 @@ public class ErrorPageTest assertThat(response,Matchers.containsString("ERROR_CODE: 598")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION: null")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION_TYPE: null")); - assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-1")); + assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-")); assertThat(response,Matchers.containsString("ERROR_REQUEST_URI: /fail/global")); } @@ -130,7 +130,7 @@ public class ErrorPageTest assertThat(response,Matchers.containsString("ERROR_CODE: 500")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION: java.lang.NumberFormatException: For input string: \"NAN\"")); assertThat(response,Matchers.containsString("ERROR_EXCEPTION_TYPE: class java.lang.NumberFormatException")); - assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-1")); + assertThat(response,Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-")); assertThat(response,Matchers.containsString("ERROR_REQUEST_URI: /fail/global")); }