From db2f4cbcb214c3c6099f97cb1ad3d25373757a55 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 16 Aug 2010 03:58:52 +0000 Subject: [PATCH] 322683 made RewriteHandler thread safe git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2211 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../jetty/rewrite/handler/LegacyRule.java | 1 + .../jetty/rewrite/handler/RewriteHandler.java | 34 +----------- .../jetty/rewrite/handler/RuleContainer.java | 55 +------------------ 4 files changed, 8 insertions(+), 83 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index c9bdf12bab1..91a6cdfc9f7 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -11,6 +11,7 @@ jetty-7.2-SNAPSHOT + 321232 BasicAuthenticator ignores bad Authorization header. + 321307 HashSessionManager calls passivation listeners. + 321730 SelectChannelEndPoint prints to System.err + + 322683 RewriteHandler thread safety + JETTY-912 added per exchange timeout api + JETTY-1245 Do not use direct buffers with NIO SSL + JETTY-1249 Apply max idle time to all connectors diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/LegacyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/LegacyRule.java index 038b02dd3f3..5762f372e4a 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/LegacyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/LegacyRule.java @@ -38,6 +38,7 @@ public class LegacyRule extends Rule } /* ------------------------------------------------------------ */ + @Override public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException { Map.Entry rewrite =_rewrite.getMatch(target); diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java index 5723fb7ca4c..98b9d0631a2 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java @@ -182,6 +182,7 @@ public class RewriteHandler extends HandlerWrapper * * @param legacyRule old style rewrite rule */ + @Deprecated public void setLegacyRule(LegacyRule legacyRule) { _rules.setLegacyRule(legacyRule); @@ -226,7 +227,6 @@ public class RewriteHandler extends HandlerWrapper { _rules.addRule(rule); } - /* ------------------------------------------------------------ */ /** @@ -289,37 +289,11 @@ public class RewriteHandler extends HandlerWrapper } - /* ------------------------------------------------------------ */ - /** - * @deprecated - */ - public PathMap getRewrite() - { - return _rules.getRewrite(); - } - - /* ------------------------------------------------------------ */ - /** - * @deprecated - */ - public void setRewrite(PathMap rewrite) - { - _rules.setRewrite(rewrite); - } - - /* ------------------------------------------------------------ */ - /** - * @deprecated - */ - public void addRewriteRule(String pattern, String prefix) - { - _rules.addRewriteRule(pattern,prefix); - } - /* ------------------------------------------------------------ */ /* (non-Javadoc) * @see org.eclipse.jetty.server.handler.HandlerWrapper#handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int) */ + @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isStarted()) @@ -327,10 +301,8 @@ public class RewriteHandler extends HandlerWrapper String returned = _rules.matchAndApply(target, request, response); target = (returned == null) ? target : returned; - if (!_rules.isHandled()) - { + if (!baseRequest.isHandled()) super.handle(target, baseRequest, request, response); - } } } diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java index e956d728f46..cf71228f154 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java @@ -34,7 +34,6 @@ import org.eclipse.jetty.util.log.Log; public class RuleContainer extends Rule { protected Rule[] _rules; - protected boolean _handled; protected String _originalPathAttribute; protected boolean _rewriteRequestURI=true; @@ -43,7 +42,8 @@ public class RuleContainer extends Rule protected LegacyRule _legacy; /* ------------------------------------------------------------ */ - private LegacyRule getLegacyRule() + @Deprecated + public LegacyRule getLegacyRule() { if (_legacy==null) { @@ -61,6 +61,7 @@ public class RuleContainer extends Rule * * @param legacyRule old style rewrite rule */ + @Deprecated public void setLegacyRule(LegacyRule legacyRule) { _legacy = legacyRule; @@ -165,54 +166,7 @@ public class RuleContainer extends Rule { _originalPathAttribute=originalPathAttribte; } - - - /* ------------------------------------------------------------ */ - /** - * @deprecated - */ - public PathMap getRewrite() - { - return getLegacyRule().getRewrite(); - } - - /* ------------------------------------------------------------ */ - /** - * @deprecated - */ - public void setRewrite(PathMap rewrite) - { - getLegacyRule().setRewrite(rewrite); - } - - /* ------------------------------------------------------------ */ - /** - * @deprecated - */ - public void addRewriteRule(String pattern, String prefix) - { - getLegacyRule().addRewriteRule(pattern,prefix); - } - - /** - * @return handled true if one of the rules within the rule container is handling the request - */ - public boolean isHandled() - { - return _handled; - } - - /*------------------------------------------------------------ */ - /** - * @param handled true if one of the rules within the rule container is handling the request - */ - public void setHandled(boolean handled) - { - _handled=handled; - } - - /** * Process the contained rules * @param target target field to pass on to the contained rules @@ -233,8 +187,6 @@ public class RuleContainer extends Rule */ protected String apply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException { - _handled=false; - boolean original_set=_originalPathAttribute==null; for (Rule rule : _rules) @@ -264,7 +216,6 @@ public class RuleContainer extends Rule if (rule.isHandling()) { Log.debug("handling {}",rule); - _handled=true; (request instanceof Request?(Request)request:HttpConnection.getCurrentConnection().getRequest()).setHandled(true); }