From 6478b5ede70be4978a2f343e5db4c20573a7adcb Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Jul 2010 00:46:34 +0000 Subject: [PATCH] improved debug dump git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2155 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../security/ConstraintSecurityHandler.java | 10 +++--- .../java/org/eclipse/jetty/server/Server.java | 14 ++++++++ .../jetty/server/handler/AbstractHandler.java | 25 +++++++++++--- .../handler/AbstractHandlerContainer.java | 22 +++++++----- .../eclipse/jetty/servlet/ServletHandler.java | 34 +++++++++---------- .../org/eclipse/jetty/webapp/MetaData.java | 6 ---- .../java/org/eclipse/jetty/xml/XmlParser.java | 3 -- .../java/org/eclipse/jetty/TestServer.java | 2 +- 9 files changed, 73 insertions(+), 44 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 88b28656ad2..89c8888029b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -9,6 +9,7 @@ jetty-7.2-SNAPSHOT + JETTY-1245 Do not use direct buffers with NIO SSL + JETTY-1249 Apply max idle time to all connectors + Added ignore to Logger interface + + Improved debug dump jetty-7.1.6.v20100715 + 319519 Warn about duplicate configuration files diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java b/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java index 3996a0df6e0..0a392504e44 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java @@ -401,6 +401,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr return ((RoleInfo)constraintInfo).isChecked(); } + @Override protected boolean checkWebResourcePermissions(String pathInContext, Request request, Response response, Object constraintInfo, UserIdentity userIdentity) throws IOException { @@ -427,15 +428,16 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr } /* ------------------------------------------------------------ */ - protected void dump(StringBuilder b,String indent) + @Override + protected void dump(Appendable out,String indent) throws IOException { - super.dump(b,indent); - b.append(indent).append(" +=roles=").append(_roles).append('\n'); + super.dump(out,indent); + out.append(indent).append(" +=roles=").append(String.valueOf(_roles)).append('\n'); for (Object path : _constraintMap.keySet()) { Object constraint = _constraintMap.get(path); - b.append(indent).append(" +=").append(path).append('=').append(constraint).append('\n'); + out.append(indent).append(" +=").append(String.valueOf(path)).append('=').append(String.valueOf(constraint)).append('\n'); } } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index 0eb13110a84..320eac3c7f3 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.HttpGenerator; import org.eclipse.jetty.http.HttpURI; +import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.HandlerWrapper; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.util.Attributes; @@ -649,12 +650,25 @@ public class Server extends HandlerWrapper implements Attributes _graceful=timeoutMS; } + /* ------------------------------------------------------------ */ @Override public String toString() { return this.getClass().getName()+"@"+Integer.toHexString(hashCode()); } + + /* ------------------------------------------------------------ */ + @Override + protected void dump(Appendable out,String indent) throws IOException + { + out.append(toString()).append(isStarted()?" started":" STOPPED").append('\n'); + for (Connector c : _connectors) + out.append(" +-").append(String.valueOf(c)).append('\n'); + out.append(" +-").append(String.valueOf(_threadPool)).append('\n'); + dumpHandlers(out,indent); + } + /* ------------------------------------------------------------ */ /* A handler that can be gracefully shutdown. diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java index 7cc8ac27c79..ae1b9e3497c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java @@ -14,6 +14,8 @@ package org.eclipse.jetty.server.handler; +import java.io.IOException; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.component.AbstractLifeCycle; @@ -106,16 +108,29 @@ public abstract class AbstractHandler extends AbstractLifeCycle implements Handl public String dump() { StringBuilder b = new StringBuilder(); - dump(b,""); + try + { + dump(b,""); + } + catch (IOException e) + { + Log.warn(e); + } return b.toString(); } /* ------------------------------------------------------------ */ - protected void dump(StringBuilder b,String indent) + public void dump(Appendable out) throws IOException { - b.append(toString()); - b.append(isStarted()?" started":" STOPPED"); - b.append('\n'); + dump(out,""); + } + + /* ------------------------------------------------------------ */ + protected void dump(Appendable out,String indent) throws IOException + { + out.append(toString()); + out.append(isStarted()?" started":" STOPPED"); + out.append('\n'); } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java index 91a65a19b17..630f04da425 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java @@ -14,6 +14,8 @@ package org.eclipse.jetty.server.handler; +import java.io.IOException; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HandlerContainer; import org.eclipse.jetty.util.LazyList; @@ -84,10 +86,14 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement /* ------------------------------------------------------------ */ @Override - protected void dump(StringBuilder b,String indent) + protected void dump(Appendable out,String indent) throws IOException + { + super.dump(out,indent); + dumpHandlers(out,indent); + } + + protected void dumpHandlers(Appendable out,String indent) throws IOException { - super.dump(b,indent); - Handler[] handlers = getHandlers(); if (handlers!=null) { @@ -96,14 +102,14 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement { if (handlers[h]==null) continue; - b.append(indent); - b.append(" +-"); + out.append(indent); + out.append(" +-"); if (handlers[h] instanceof AbstractHandler) - ((AbstractHandler)handlers[h]).dump(b,indent+((h==last)?" ":" | ")); + ((AbstractHandler)handlers[h]).dump(out,indent+((h==last)?" ":" | ")); else { - b.append(handlers[h]); - b.append("\n"); + out.append(String.valueOf(handlers[h])); + out.append("\n"); } } } 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 a0abf33d177..8a7387c143a 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 @@ -1409,19 +1409,19 @@ public class ServletHandler extends ScopedHandler /* ------------------------------------------------------------ */ @Override - protected void dump(StringBuilder b,String indent) + protected void dump(Appendable out,String indent) throws IOException { - super.dump(b,indent); + super.dump(out,indent); if (getFilterMappings()!=null) { for (FilterMapping f : getFilterMappings()) { - b.append(indent); - b.append(" +-"); - b.append(f); - b.append(f.getFilterHolder().getInitParameters()); - b.append('\n'); + out.append(indent); + out.append(" +-"); + out.append(String.valueOf(f.toString())); + out.append(String.valueOf(f.getFilterHolder().getInitParameters())); + out.append('\n'); } } HashSet servlets = new HashSet(); @@ -1430,13 +1430,13 @@ public class ServletHandler extends ScopedHandler for (ServletMapping m : getServletMappings()) { servlets.add(m.getServletName()); - b.append(indent); - b.append(" +-"); - b.append(m); + out.append(indent); + out.append(" +-"); + out.append(String.valueOf(m)); ServletHolder h = getServlet(m.getServletName()); if (h!=null) - b.append(h.getInitParameters()); - b.append('\n'); + out.append(String.valueOf(h.getInitParameters())); + out.append('\n'); } } @@ -1446,11 +1446,11 @@ public class ServletHandler extends ScopedHandler { if (servlets.contains(h.getName())) continue; - b.append(indent); - b.append(" +-[]==>"); - b.append(h.getName()); - b.append(h.getInitParameters()); - b.append('\n'); + out.append(indent); + out.append(" +-[]==>"); + out.append(h.getName()); + out.append(String.valueOf(h.getInitParameters())); + out.append('\n'); } } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java index 9d855f0a1ec..13b7ed91f06 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java @@ -136,7 +136,6 @@ public class MetaData * Order the list of jars in WEB-INF/lib according to the ordering declarations in the descriptors * @see org.eclipse.jetty.webapp.MetaData.Ordering#order(java.util.List) */ - @Override public List order(List jars) { List orderedList = new ArrayList(); @@ -174,7 +173,6 @@ public class MetaData return orderedList; } - @Override public boolean isAbsolute() { return true; @@ -194,7 +192,6 @@ public class MetaData _order.add(OTHER); } - @Override public boolean hasOther () { return _hasOther; @@ -218,7 +215,6 @@ public class MetaData * in the various web-fragment.xml files. * @see org.eclipse.jetty.webapp.MetaData.Ordering#order(java.util.List) */ - @Override public List order(List jars) { //for each jar, put it into the ordering according to the fragment ordering @@ -288,13 +284,11 @@ public class MetaData return orderedList; } - @Override public boolean isAbsolute () { return false; } - @Override public boolean hasOther () { return !_beforeOthers.isEmpty() || !_afterOthers.isEmpty(); diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlParser.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlParser.java index e8b5f037de6..4e891b402bc 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlParser.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlParser.java @@ -749,7 +749,6 @@ public class XmlParser Node _node; /* -------------------------------------------------- */ - @Override public boolean hasNext() { if (_node != null) @@ -772,7 +771,6 @@ public class XmlParser } /* -------------------------------------------------- */ - @Override public Node next() { try @@ -789,7 +787,6 @@ public class XmlParser } /* -------------------------------------------------- */ - @Override public void remove() { throw new UnsupportedOperationException("Not supported"); diff --git a/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java b/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java index d011e25ac6f..a1f91863564 100644 --- a/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java +++ b/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java @@ -37,7 +37,7 @@ public class TestServer { public static void main(String[] args) throws Exception { - Log.getLog().setDebugEnabled(false); + Log.getLog().setDebugEnabled(true); ((StdErrLog)Log.getLog()).setSource(false); String jetty_root = "..";