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
This commit is contained in:
Greg Wilkins 2013-10-04 14:00:58 +10:00
parent 1315096192
commit 7cb553557e
4 changed files with 7 additions and 10 deletions

View File

@ -216,6 +216,8 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
{
_className = className;
_class=null;
if (_name==null)
_name=className+"-"+Integer.toHexString(this.hashCode());
}
/* ------------------------------------------------------------ */
@ -229,7 +231,7 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
{
_className=held.getName();
if (_name==null)
_name=held.getName()+"-"+this.hashCode();
_name=held.getName()+"-"+Integer.toHexString(this.hashCode());
}
}

View File

@ -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<DispatcherType> 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);

View File

@ -199,8 +199,6 @@ public class ServletHolder extends Holder<Servlet> 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;
}

View File

@ -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"));
}