(tomcat) branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 3f9950cd9c Align with 9.0.x onwards 3f9950cd9c is described below commit 3f9950cd9caea493e1345c6ad2ce7e3b2da1a9fc Author: Mark Thomas AuthorDate: Mon Jan 15 13:43:49 2024 + Align with 9.0.x onwards --- .../apache/catalina/ssi/ExpressionParseTree.java | 2 +- .../catalina/ssi/ResponseIncludeWrapper.java | 30 +- .../catalina/ssi/SSIServletExternalResolver.java | 3 --- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/java/org/apache/catalina/ssi/ExpressionParseTree.java b/java/org/apache/catalina/ssi/ExpressionParseTree.java index 1199f6b1f7..3c199787b1 100644 --- a/java/org/apache/catalina/ssi/ExpressionParseTree.java +++ b/java/org/apache/catalina/ssi/ExpressionParseTree.java @@ -404,7 +404,7 @@ public class ExpressionParseTree { return -1; } } catch (PatternSyntaxException pse) { -ssiMediator.log("Invalid expression: " + expr, pse); + ssiMediator.log(sm.getString("expressionParseTree.invalidExpression", expr), pse); return 0; } } diff --git a/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java b/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java index 1a59760f91..50cb5f09d7 100644 --- a/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java +++ b/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java @@ -19,16 +19,13 @@ package org.apache.catalina.ssi; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.Locale; -import java.util.TimeZone; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import org.apache.tomcat.util.ExceptionUtils; +import org.apache.tomcat.util.http.FastHttpDateFormat; /** * An HttpServletResponseWrapper, used from SSIServletExternalResolver @@ -41,8 +38,6 @@ public class ResponseIncludeWrapper extends HttpServletResponseWrapper { * The names of some headers we want to capture. */ private static final String LAST_MODIFIED = "last-modified"; -private static final DateFormat RFC1123_FORMAT; -private static final String RFC1123_PATTERN = "EEE, dd MMM HH:mm:ss z"; protected long lastModified = -1; @@ -53,11 +48,6 @@ public class ResponseIncludeWrapper extends HttpServletResponseWrapper { protected ServletOutputStream servletOutputStream; protected PrintWriter printWriter; -static { -RFC1123_FORMAT = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); -RFC1123_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); -} - /** * Initialize our wrapper with the current HttpServletResponse and ServletOutputStream. * @@ -151,12 +141,9 @@ public class ResponseIncludeWrapper extends HttpServletResponseWrapper { super.addHeader(name, value); String lname = name.toLowerCase(Locale.ENGLISH); if (lname.equals(LAST_MODIFIED)) { -try { -synchronized (RFC1123_FORMAT) { -lastModified = RFC1123_FORMAT.parse(value).getTime(); -} -} catch (Throwable ignore) { -ExceptionUtils.handleThrowable(ignore); +long lastModified = FastHttpDateFormat.parseDate(value); +if (lastModified != -1) { +this.lastModified = lastModified; } } } @@ -175,12 +162,9 @@ public class ResponseIncludeWrapper extends HttpServletResponseWrapper { super.setHeader(name, value); String lname = name.toLowerCase(Locale.ENGLISH); if (lname.equals(LAST_MODIFIED)) { -try { -synchronized (RFC1123_FORMAT) { -lastModified = RFC1123_FORMAT.parse(value).getTime(); -} -} catch (Throwable ignore) { -ExceptionUtils.handleThrowable(ignore); +long lastModified = FastHttpDateFormat.parseDate(value); +if (lastModified != -1) { +this.lastModified = lastModified; } } } diff --git a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java index cbf2492490..67b1b02da1 100644 --- a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java +++ b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java @@ -410,9 +410,6 @@ public class SSIServletExternalResolver implements SSIExternalResolver { // ie: '/file1.shtml' vs
(tomcat) branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 705838d34c Align with 9.0.x onwards 705838d34c is described below commit 705838d34c951dd39face65a152200b8c3958383 Author: Mark Thomas AuthorDate: Mon Jan 15 08:05:57 2024 + Align with 9.0.x onwards --- java/org/apache/catalina/session/ManagerBase.java | 11 ++- java/org/apache/catalina/session/StoreBase.java | 11 ++- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/java/org/apache/catalina/session/ManagerBase.java b/java/org/apache/catalina/session/ManagerBase.java index 514d7603e2..7e048d1862 100644 --- a/java/org/apache/catalina/session/ManagerBase.java +++ b/java/org/apache/catalina/session/ManagerBase.java @@ -46,6 +46,7 @@ import org.apache.catalina.SessionIdGenerator; import org.apache.catalina.util.LifecycleMBeanBase; import org.apache.catalina.util.SessionIdGeneratorBase; import org.apache.catalina.util.StandardSessionIdGenerator; +import org.apache.catalina.util.ToStringUtil; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.res.StringManager; @@ -1247,15 +1248,7 @@ public abstract class ManagerBase extends LifecycleMBeanBase implements Manager @Override public String toString() { -StringBuilder sb = new StringBuilder(this.getClass().getName()); -sb.append('['); -if (context == null) { -sb.append("Context is null"); -} else { -sb.append(context.getName()); -} -sb.append(']'); -return sb.toString(); +return ToStringUtil.toString(this, context); } diff --git a/java/org/apache/catalina/session/StoreBase.java b/java/org/apache/catalina/session/StoreBase.java index 4b76462634..222864a6d6 100644 --- a/java/org/apache/catalina/session/StoreBase.java +++ b/java/org/apache/catalina/session/StoreBase.java @@ -29,6 +29,7 @@ import org.apache.catalina.Manager; import org.apache.catalina.Store; import org.apache.catalina.util.CustomObjectInputStream; import org.apache.catalina.util.LifecycleBase; +import org.apache.catalina.util.ToStringUtil; import org.apache.tomcat.util.res.StringManager; /** @@ -270,14 +271,6 @@ public abstract class StoreBase extends LifecycleBase implements Store { */ @Override public String toString() { -StringBuilder sb = new StringBuilder(this.getClass().getName()); -sb.append('['); -if (manager == null) { -sb.append("Manager is null"); -} else { -sb.append(manager); -} -sb.append(']'); -return sb.toString(); +return ToStringUtil.toString(this, manager); } } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 3fa0789a87 Align with 9.0.x onwards 3fa0789a87 is described below commit 3fa0789a87d3c1c397e1db148d6bffac3a0a878b Author: Mark Thomas AuthorDate: Thu Sep 21 16:30:28 2023 +0100 Align with 9.0.x onwards --- .../catalina/manager/HTMLManagerServlet.java | 404 + .../apache/catalina/manager/JMXProxyServlet.java | 2 +- .../catalina/manager/LocalStrings.properties | 13 + .../catalina/manager/LocalStrings_fr.properties| 13 + .../catalina/manager/LocalStrings_ja.properties| 13 + .../catalina/manager/LocalStrings_ko.properties| 13 + .../catalina/manager/LocalStrings_zh_CN.properties | 13 + .../apache/catalina/manager/ManagerServlet.java| 28 +- .../catalina/manager/StatusManagerServlet.java | 10 +- .../apache/catalina/manager/StatusTransformer.java | 32 +- .../apache/catalina/manager/util/SessionUtils.java | 2 +- 11 files changed, 267 insertions(+), 276 deletions(-) diff --git a/java/org/apache/catalina/manager/HTMLManagerServlet.java b/java/org/apache/catalina/manager/HTMLManagerServlet.java index 0297565b9f..82aacb3506 100644 --- a/java/org/apache/catalina/manager/HTMLManagerServlet.java +++ b/java/org/apache/catalina/manager/HTMLManagerServlet.java @@ -53,24 +53,20 @@ import org.apache.tomcat.util.res.StringManager; import org.apache.tomcat.util.security.Escape; /** - * Servlet that enables remote management of the web applications deployed - * within the same virtual host as this web application is. Normally, this - * functionality will be protected by a security constraint in the web - * application deployment descriptor. However, this requirement can be - * relaxed during testing. + * Servlet that enables remote management of the web applications deployed within the same virtual host as this web + * application is. Normally, this functionality will be protected by a security constraint in the web application + * deployment descriptor. However, this requirement can be relaxed during testing. * - * The difference between the ManagerServlet and this - * Servlet is that this Servlet prints out a HTML interface which - * makes it easier to administrate. + * The difference between the ManagerServlet and this Servlet is that this Servlet prints out an HTML + * interface which makes it easier to administrate. * - * However if you use a software that parses the output of - * ManagerServlet you won't be able to upgrade - * to this Servlet since the output are not in the - * same format ar from ManagerServlet + * However if you use a software that parses the output of ManagerServlet you won't be able to upgrade to + * this Servlet since the output are not in the same format ar from ManagerServlet * * @author Bip Thelin * @author Malcolm Edgar * @author Glenn L. Nielsen + * * @see ManagerServlet */ public final class HTMLManagerServlet extends ManagerServlet { @@ -93,19 +89,16 @@ public final class HTMLManagerServlet extends ManagerServlet { /** * Process a GET request for the specified resource. * - * @param request The servlet request we are processing + * @param request The servlet request we are processing * @param response The servlet response we are creating * - * @exception IOException if an input/output error occurs + * @exception IOException if an input/output error occurs * @exception ServletException if a servlet-specified error occurs */ @Override -public void doGet(HttpServletRequest request, - HttpServletResponse response) -throws IOException, ServletException { +public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { -StringManager smClient = StringManager.getManager( -Constants.Package, request.getLocales()); +StringManager smClient = StringManager.getManager(Constants.Package, request.getLocales()); // Identify the request parameters that we need // By obtaining the command from the pathInfo, per-command security can @@ -132,9 +125,8 @@ public final class HTMLManagerServlet extends ManagerServlet { doSessions(cn, request, response, smClient); return; } catch (Exception e) { -log("HTMLManagerServlet.sessions[" + cn + "]", e); -message = smClient.getString("managerServlet.exception", -e.toString()); +log(sm.getString("htmlManagerServlet.error.sessions", cn), e); +message = smClient.getString("managerServlet.exception", e.toString()); } } else if
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new cae270d2a3 Align with 9.0.x onwards cae270d2a3 is described below commit cae270d2a3a7381943848efc7959ec5b8e475d0e Author: Mark Thomas AuthorDate: Tue Aug 8 14:25:58 2023 +0100 Align with 9.0.x onwards --- java/org/apache/catalina/ha/ClusterRuleSet.java| 5 - .../apache/catalina/ha/backend/CollectedInfo.java | 24 +++-- .../catalina/ha/backend/HeartbeatListener.java | 119 +++-- .../catalina/ha/backend/MultiCastSender.java | 2 +- .../apache/catalina/ha/deploy/FarmWarDeployer.java | 6 +- .../catalina/ha/deploy/FileMessageFactory.java | 3 + .../catalina/ha/deploy/LocalStrings.properties | 3 +- .../catalina/ha/deploy/LocalStrings_fr.properties | 2 + .../catalina/ha/deploy/LocalStrings_ja.properties | 2 + .../catalina/ha/deploy/LocalStrings_ko.properties | 2 + .../ha/deploy/LocalStrings_zh_CN.properties| 2 + .../ha/session/ClusterSessionListener.java | 2 +- .../apache/catalina/ha/session/DeltaManager.java | 7 ++ .../apache/catalina/ha/session/DeltaSession.java | 2 +- .../catalina/ha/tcp/LocalStrings_es.properties | 1 - .../apache/catalina/ha/tcp/SimpleTcpCluster.java | 23 ++-- java/org/apache/catalina/util/ToStringUtil.java| 62 +++ 17 files changed, 221 insertions(+), 46 deletions(-) diff --git a/java/org/apache/catalina/ha/ClusterRuleSet.java b/java/org/apache/catalina/ha/ClusterRuleSet.java index 8aed8fefff..a24ed5f29e 100644 --- a/java/org/apache/catalina/ha/ClusterRuleSet.java +++ b/java/org/apache/catalina/ha/ClusterRuleSet.java @@ -16,11 +16,9 @@ */ package org.apache.catalina.ha; - import org.apache.tomcat.util.digester.Digester; import org.apache.tomcat.util.digester.RuleSetBase; - /** * * RuleSet for processing the contents of a Cluster definition element. @@ -48,9 +46,7 @@ public class ClusterRuleSet extends RuleSetBase { * Construct an instance of this RuleSet with the default matching pattern prefix. */ public ClusterRuleSet() { - this(""); - } @@ -60,7 +56,6 @@ public class ClusterRuleSet extends RuleSetBase { * @param prefix Prefix for matching pattern rules (including the trailing slash character) */ public ClusterRuleSet(String prefix) { -super(); this.prefix = prefix; } diff --git a/java/org/apache/catalina/ha/backend/CollectedInfo.java b/java/org/apache/catalina/ha/backend/CollectedInfo.java index 235e161df1..ab2436717c 100644 --- a/java/org/apache/catalina/ha/backend/CollectedInfo.java +++ b/java/org/apache/catalina/ha/backend/CollectedInfo.java @@ -61,7 +61,13 @@ public class CollectedInfo { Set set = mBeanServer.queryMBeans(objectName, null); for (ObjectInstance oi : set) { objName = oi.getObjectName(); +String subtype = objName.getKeyProperty("subType"); +if (subtype != null && subtype.equals("SocketProperties")) { +objName = null; +continue; +} String name = objName.getKeyProperty("name"); +name = name.replace("\"", ""); // Example names: // ajp-nio-8009 @@ -71,18 +77,22 @@ public class CollectedInfo { String[] elenames = name.split("-"); String sport = elenames[elenames.length - 1]; iport = Integer.parseInt(sport); -String[] shosts = elenames[1].split("%2F"); -shost = shosts[0]; +if (elenames.length == 4) { +shost = elenames[2]; +} if (port == 0 && host == null) { break; /* Done: take the first one */ } -if (host == null && iport == port) { -break; /* Only port done */ -} -if (shost.compareTo(host) == 0) { -break; /* Done port and host are the expected ones */ +if (iport == port) { +if (host == null) { +break; /* Done: return the first with the right port */ +} else if (shost != null && shost.compareTo(host) == 0) { +break; /* Done port and host are the expected ones */ +} } +objName = null; +shost = null; } if (objName == null) { throw new Exception(sm.getString("collectedInfo.noConnector", host, Integer.valueOf(port))); diff --git a/java/org/apache/catalina/ha/backend/HeartbeatListener.java b/java/org/apache/catalina/ha/backend/HeartbeatListener.java index de6dfcada4..8cd64304b3 100644 --- a/java/org/apache/catalina/ha/backend/HeartbeatListener.java +++
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards (fixes failing test)
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 4f04558f14 Align with 9.0.x onwards (fixes failing test) 4f04558f14 is described below commit 4f04558f1421cd8279b09f9571bddb30572d55ef Author: Mark Thomas AuthorDate: Tue Jun 27 11:49:28 2023 +0100 Align with 9.0.x onwards (fixes failing test) --- test/org/apache/tomcat/util/net/TestCustomSslTrustManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/org/apache/tomcat/util/net/TestCustomSslTrustManager.java b/test/org/apache/tomcat/util/net/TestCustomSslTrustManager.java index b8b21b788e..f2afd93806 100644 --- a/test/org/apache/tomcat/util/net/TestCustomSslTrustManager.java +++ b/test/org/apache/tomcat/util/net/TestCustomSslTrustManager.java @@ -123,8 +123,7 @@ public class TestCustomSslTrustManager extends TomcatBaseTest { if (trustType.equals(TrustType.NONE)) { Assert.assertTrue(rc != 200); -Assert.assertNotNull(res); -Assert.assertTrue(res.toString().isEmpty()); +Assert.assertNull(res.toString()); } else { Assert.assertEquals(200, rc); Assert.assertEquals("OK-" + TesterSupport.ROLE, res.toString()); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards - harden the default HTTP configuration
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new a1efd94f75 Align with 9.0.x onwards - harden the default HTTP configuration a1efd94f75 is described below commit a1efd94f7506d0bf113a0c225ad6f3fb9af08307 Author: Mark Thomas AuthorDate: Tue May 2 14:28:43 2023 +0100 Align with 9.0.x onwards - harden the default HTTP configuration --- java/org/apache/coyote/http11/AbstractHttp11Protocol.java | 2 +- webapps/docs/changelog.xml| 6 ++ webapps/docs/config/http.xml | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java index c4e4fcf218..2b1d75b124 100644 --- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java +++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java @@ -195,7 +195,7 @@ public abstract class AbstractHttp11Protocol extends AbstractProtocol { } -private boolean rejectIllegalHeader = false; +private boolean rejectIllegalHeader = true; /** * If an HTTP request is received that contains an illegal header name or value (e.g. the header name is not a diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index ebf9552cb6..6f989bdd51 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -148,6 +148,12 @@ true to false to harden the default configuration. (markt) + +The default for the HTTP Connector attribute +rejectIllegalHeader has been changed from +false to true to harden the default +configuration. (markt) + diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index 429c04f485..11f660d6cc 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -632,8 +632,7 @@ value (e.g. the header name is not a token) this setting determines if the request will be rejected with a 400 response (true) or if the illegal header be ignored (false). The default value is - false which will cause the request to be processed but the - illegal header will be ignored. + true which will cause the request to be rejected. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards - harden the default HTTP configuration
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 4bbfd89dab Align with 9.0.x onwards - harden the default HTTP configuration 4bbfd89dab is described below commit 4bbfd89dab9e62d77d7fd968a3c15b86ff364e62 Author: Mark Thomas AuthorDate: Tue May 2 14:25:58 2023 +0100 Align with 9.0.x onwards - harden the default HTTP configuration --- java/org/apache/coyote/http11/AbstractHttp11Protocol.java | 2 +- webapps/docs/changelog.xml| 6 ++ webapps/docs/config/http.xml | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java index a337f07234..c4e4fcf218 100644 --- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java +++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java @@ -172,7 +172,7 @@ public abstract class AbstractHttp11Protocol extends AbstractProtocol { } -private boolean allowHostHeaderMismatch = true; +private boolean allowHostHeaderMismatch = false; /** * Will Tomcat accept an HTTP 1.1 request where the host header does not agree with the host specified (if any) in diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 5e851fbde2..ebf9552cb6 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -142,6 +142,12 @@ Add support for a new character set, gb18030-2022 - introduced in Java 21, to the character set caching mechanism. (markt) + +The default for the HTTP Connector attribute +allowHostHeaderMismatch has been changed from +true to false to harden the default +configuration. (markt) + diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index 30f032ab80..429c04f485 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -342,10 +342,10 @@ - By default Tomcat will allow requests that specify a host in the + By default Tomcat will reject requests that specify a host in the request line but specify a different host in the host header. This - check can be enabled by setting this attribute to false. If - not specified, the default is true. + check can be disabled by setting this attribute to true. If + not specified, the default is false. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards - renames
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new ccefd00 Align with 9.0.x onwards - renames ccefd00 is described below commit ccefd007161e62fc52f7b7828b901657b5c857c8 Author: Mark Thomas AuthorDate: Thu Feb 17 22:18:46 2022 + Align with 9.0.x onwards - renames --- java/org/apache/tomcat/util/net/NioEndpoint.java | 63 +--- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 62471d9..4c6f244 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -828,21 +828,21 @@ public class NioEndpoint extends AbstractJsseEndpoint addEvent(event); } -public NioSocketWrapper cancelledKey(SelectionKey key) { +public NioSocketWrapper cancelledKey(SelectionKey sk) { NioSocketWrapper ka = null; try { -if ( key == null ) +if ( sk == null ) { return null;//nothing to do } -ka = (NioSocketWrapper) key.attach(null); +ka = (NioSocketWrapper) sk.attach(null); if (ka != null) { // If attachment is non-null then there may be a current // connection with an associated processor. getHandler().release(ka); } -if (key.isValid()) { -key.cancel(); +if (sk.isValid()) { +sk.cancel(); } // If it is available, close the NioChannel first which should // in turn close the underlying SocketChannel. The NioChannel @@ -860,9 +860,9 @@ public class NioEndpoint extends AbstractJsseEndpoint } // The SocketChannel is also available via the SelectionKey. If // it hasn't been closed in the block above, close it now. -if (key.channel().isOpen()) { +if (sk.channel().isOpen()) { try { -key.channel().close(); +sk.channel().close(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug(sm.getString( @@ -957,25 +957,25 @@ public class NioEndpoint extends AbstractJsseEndpoint getStopLatch().countDown(); } -protected void processKey(SelectionKey sk, NioSocketWrapper attachment) { +protected void processKey(SelectionKey sk, NioSocketWrapper socketWrapper) { try { if (close) { cancelledKey(sk); -} else if (sk.isValid() && attachment != null ) { +} else if (sk.isValid() && socketWrapper != null ) { if (sk.isReadable() || sk.isWritable() ) { -if (attachment.getSendfileData() != null ) { -processSendfile(sk, attachment, false); +if (socketWrapper.getSendfileData() != null ) { +processSendfile(sk, socketWrapper, false); } else { -unreg(sk, attachment, sk.readyOps()); +unreg(sk, socketWrapper, sk.readyOps()); boolean closeSocket = false; // Read goes before write if (sk.isReadable()) { -if (!processSocket(attachment, SocketEvent.OPEN_READ, true)) { +if (!processSocket(socketWrapper, SocketEvent.OPEN_READ, true)) { closeSocket = true; } } if (!closeSocket && sk.isWritable()) { -if (!processSocket(attachment, SocketEvent.OPEN_WRITE, true)) { +if (!processSocket(socketWrapper, SocketEvent.OPEN_WRITE, true)) { closeSocket = true; } } @@ -1133,34 +1133,37 @@ public class NioEndpoint extends AbstractJsseEndpoint try { for (SelectionKey key : selector.keys()) { keycount++; +NioSocketWrapper socketWrapper = (NioSocketWrapper) key.attachment(); try { -NioSocketWrapper ka = (NioSocketWrapper) key.attachment(); -if ( ka == null ) { -
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards - backport NPE protection
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 2f6ce58 Align with 9.0.x onwards - backport NPE protection 2f6ce58 is described below commit 2f6ce585a11e9990e898dc9f92bda444b6f6fd07 Author: Mark Thomas AuthorDate: Thu Feb 17 21:39:03 2022 + Align with 9.0.x onwards - backport NPE protection --- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 118 +- 1 file changed, 68 insertions(+), 50 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index a32f636..e480490 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -1475,30 +1475,36 @@ public class Nio2Endpoint extends AbstractJsseEndpoint
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new ffb7527 Align with 9.0.x onwards ffb7527 is described below commit ffb7527b9a83bb4d849add0c4339504baa2394f7 Author: Mark Thomas AuthorDate: Thu Feb 17 17:41:23 2022 + Align with 9.0.x onwards --- java/org/apache/coyote/http11/Http11Nio2Protocol.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11Nio2Protocol.java b/java/org/apache/coyote/http11/Http11Nio2Protocol.java index de520ef..e30b41a 100644 --- a/java/org/apache/coyote/http11/Http11Nio2Protocol.java +++ b/java/org/apache/coyote/http11/Http11Nio2Protocol.java @@ -44,9 +44,9 @@ public class Http11Nio2Protocol extends AbstractHttp11JsseProtocol @Override protected String getNamePrefix() { if (isSSLEnabled()) { -return ("https-" + getSslImplementationShortName()+ "-nio2"); +return "https-" + getSslImplementationShortName()+ "-nio2"; } else { -return ("http-nio2"); +return "http-nio2"; } } } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new d53e62d Align with 9.0.x onwards d53e62d is described below commit d53e62d1e13621970eb21fcbb59942e3a516d04a Author: Mark Thomas AuthorDate: Thu Feb 17 16:55:10 2022 + Align with 9.0.x onwards Back-port NPE protection and align formatting --- java/org/apache/tomcat/util/net/NioEndpoint.java | 63 +++- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index cce04ff..7249534 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -613,7 +613,6 @@ public class NioEndpoint extends AbstractJsseEndpoint // - Poller Inner Classes /** - * * PollerEvent, cacheable object for poller events to avoid GC */ public static class PollerEvent implements Runnable { @@ -692,7 +691,8 @@ public class NioEndpoint extends AbstractJsseEndpoint new SynchronizedQueue<>(); private volatile boolean close = false; -private long nextExpiration = 0;//optimize expiration handling +// Optimize expiration handling +private long nextExpiration = 0; private AtomicLong wakeupCounter = new AtomicLong(0); @@ -704,7 +704,7 @@ public class NioEndpoint extends AbstractJsseEndpoint public int getKeyCount() { return keyCount; } -public Selector getSelector() { return selector;} +public Selector getSelector() { return selector; } /** * Destroy the poller. @@ -997,7 +997,7 @@ public class NioEndpoint extends AbstractJsseEndpoint socketWrapper.updateLastWrite(); } } else { -long written = sd.fchannel.transferTo(sd.pos,sd.length,wc); +long written = sd.fchannel.transferTo(sd.pos, sd.length, wc); if (written > 0) { sd.pos += written; sd.length -= written; @@ -1062,9 +1062,9 @@ public class NioEndpoint extends AbstractJsseEndpoint } return SendfileState.PENDING; } -} catch (IOException x) { +} catch (IOException e) { if (log.isDebugEnabled()) { -log.debug("Unable to complete sendfile request:", x); +log.debug("Unable to complete sendfile request:", e); } if (!calledByProcessor && sc != null) { close(sc, sk); @@ -1429,20 +1429,26 @@ public class NioEndpoint extends AbstractJsseEndpoint @Override protected void populateRemoteAddr() { -InetAddress inetAddr = getSocket().getIOChannel().socket().getInetAddress(); -if (inetAddr != null) { -remoteAddr = inetAddr.getHostAddress(); +SocketChannel sc = getSocket().getIOChannel(); +if (sc != null) { +InetAddress inetAddr = sc.socket().getInetAddress(); +if (inetAddr != null) { +remoteAddr = inetAddr.getHostAddress(); +} } } @Override protected void populateRemoteHost() { -InetAddress inetAddr = getSocket().getIOChannel().socket().getInetAddress(); -if (inetAddr != null) { -remoteHost = inetAddr.getHostName(); -if (remoteAddr == null) { -remoteAddr = inetAddr.getHostAddress(); +SocketChannel sc = getSocket().getIOChannel(); +if (sc != null) { +InetAddress inetAddr = sc.socket().getInetAddress(); +if (inetAddr != null) { +remoteHost = inetAddr.getHostName(); +if (remoteAddr == null) { +remoteAddr = inetAddr.getHostAddress(); +} } } } @@ -1450,31 +1456,43 @@ public class NioEndpoint extends AbstractJsseEndpoint @Override protected void populateRemotePort() { -remotePort = getSocket().getIOChannel().socket().getPort(); +SocketChannel sc = getSocket().getIOChannel(); +if (sc != null) { +remotePort = sc.socket().getPort(); +} } @Override protected void populateLocalName() { -InetAddress inetAddr = getSocket().getIOChannel().socket().getLocalAddress(); -if (inetAddr != null) { -localName =
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards - Prep for backporting socket close changes
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 67e70a2 Align with 9.0.x onwards - Prep for backporting socket close changes 67e70a2 is described below commit 67e70a2fbe2b9d777406e33b3317267419414332 Author: Mark Thomas AuthorDate: Thu Feb 17 15:39:15 2022 + Align with 9.0.x onwards - Prep for backporting socket close changes --- .../tomcat/util/net/ApplicationBufferHandler.java | 15 java/org/apache/tomcat/util/net/Nio2Channel.java | 85 ++ java/org/apache/tomcat/util/net/WriteBuffer.java | 3 + 3 files changed, 103 insertions(+) diff --git a/java/org/apache/tomcat/util/net/ApplicationBufferHandler.java b/java/org/apache/tomcat/util/net/ApplicationBufferHandler.java index d9a22ed..8362416 100644 --- a/java/org/apache/tomcat/util/net/ApplicationBufferHandler.java +++ b/java/org/apache/tomcat/util/net/ApplicationBufferHandler.java @@ -24,6 +24,21 @@ import java.nio.ByteBuffer; */ public interface ApplicationBufferHandler { +static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0); + +static ApplicationBufferHandler EMPTY = new ApplicationBufferHandler() { +@Override +public void expand(int newSize) { +} +@Override +public void setByteBuffer(ByteBuffer buffer) { +} +@Override +public ByteBuffer getByteBuffer() { +return EMPTY_BUFFER; +} +}; + public void setByteBuffer(ByteBuffer buffer); public ByteBuffer getByteBuffer(); diff --git a/java/org/apache/tomcat/util/net/Nio2Channel.java b/java/org/apache/tomcat/util/net/Nio2Channel.java index f5dd0f3..a22b7ab 100644 --- a/java/org/apache/tomcat/util/net/Nio2Channel.java +++ b/java/org/apache/tomcat/util/net/Nio2Channel.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousByteChannel; import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.ClosedChannelException; import java.nio.channels.CompletionHandler; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -220,4 +221,88 @@ public class Nio2Channel implements AsynchronousByteChannel { protected ApplicationBufferHandler getAppReadBufHandler() { return appReadBufHandler; } + +private static final Future DONE_INT = new Future() { +@Override +public boolean cancel(boolean mayInterruptIfRunning) { +return false; +} +@Override +public boolean isCancelled() { +return false; +} +@Override +public boolean isDone() { +return true; +} +@Override +public Integer get() throws InterruptedException, +ExecutionException { +return Integer.valueOf(-1); +} +@Override +public Integer get(long timeout, TimeUnit unit) +throws InterruptedException, ExecutionException, +TimeoutException { +return Integer.valueOf(-1); +} +}; + +static final Nio2Channel CLOSED_NIO2_CHANNEL = new Nio2Channel(SocketBufferHandler.EMPTY) { +@Override +public void close() throws IOException { +} +@Override +public boolean isOpen() { +return false; +} +@Override +public void reset(AsynchronousSocketChannel channel, SocketWrapperBase socket) throws IOException { +} +@Override +public void free() { +} +@Override +protected ApplicationBufferHandler getAppReadBufHandler() { +return ApplicationBufferHandler.EMPTY; +} +@Override +public void setAppReadBufHandler(ApplicationBufferHandler handler) { +} +@Override +public Future read(ByteBuffer dst) { +return DONE_INT; +} +@Override +public void read(ByteBuffer dst, +long timeout, TimeUnit unit, A attachment, +CompletionHandler handler) { +handler.failed(new ClosedChannelException(), attachment); +} +@Override +public void read(ByteBuffer[] dsts, +int offset, int length, long timeout, TimeUnit unit, +A attachment, CompletionHandler handler) { +handler.failed(new ClosedChannelException(), attachment); +} +@Override +public Future write(ByteBuffer src) { +return DONE_INT; +} +@Override +public void write(ByteBuffer src, long timeout, TimeUnit unit, A attachment, +CompletionHandler handler) { +handler.failed(new ClosedChannelException(), attachment); +} +
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new f66c10f Align with 9.0.x onwards f66c10f is described below commit f66c10fe14eca366486169f4fa2172382d4a8583 Author: Mark Thomas AuthorDate: Thu Feb 17 10:10:15 2022 + Align with 9.0.x onwards --- java/org/apache/tomcat/util/net/SecureNio2Channel.java | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/org/apache/tomcat/util/net/SecureNio2Channel.java b/java/org/apache/tomcat/util/net/SecureNio2Channel.java index 1f537e4..0ebc702 100644 --- a/java/org/apache/tomcat/util/net/SecureNio2Channel.java +++ b/java/org/apache/tomcat/util/net/SecureNio2Channel.java @@ -58,24 +58,24 @@ public class SecureNio2Channel extends Nio2Channel { // various scenarios private static final int DEFAULT_NET_BUFFER_SIZE = 16921; +protected final Nio2Endpoint endpoint; + protected ByteBuffer netInBuffer; protected ByteBuffer netOutBuffer; protected SSLEngine sslEngine; -protected final Nio2Endpoint endpoint; protected volatile boolean sniComplete = false; -private volatile boolean handshakeComplete; +private volatile boolean handshakeComplete = false; private volatile HandshakeStatus handshakeStatus; //gets set by handshake -private volatile boolean unwrapBeforeRead; - protected boolean closed; protected boolean closing; private final Map> additionalTlsAttributes = new HashMap<>(); +private volatile boolean unwrapBeforeRead; private final CompletionHandler> handshakeReadCompletionHandler; private final CompletionHandler> handshakeWriteCompletionHandler; @@ -1268,4 +1268,4 @@ public class SecureNio2Channel extends Nio2Channel { public ByteBuffer getEmptyBuf() { return emptyBuf; } -} \ No newline at end of file +} - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new e7d446b Align with 9.0.x onwards e7d446b is described below commit e7d446bae35f5a0ef6bca294c336158b784f6390 Author: Mark Thomas AuthorDate: Wed Feb 16 19:58:46 2022 + Align with 9.0.x onwards --- java/org/apache/tomcat/util/net/Nio2Channel.java | 5 ++--- java/org/apache/tomcat/util/net/NioChannel.java | 10 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Nio2Channel.java b/java/org/apache/tomcat/util/net/Nio2Channel.java index bc5a8b3..f5dd0f3 100644 --- a/java/org/apache/tomcat/util/net/Nio2Channel.java +++ b/java/org/apache/tomcat/util/net/Nio2Channel.java @@ -35,9 +35,9 @@ public class Nio2Channel implements AsynchronousByteChannel { protected static final ByteBuffer emptyBuf = ByteBuffer.allocate(0); +protected final SocketBufferHandler bufHandler; protected AsynchronousSocketChannel sc = null; protected SocketWrapperBase socket = null; -protected final SocketBufferHandler bufHandler; public Nio2Channel(SocketBufferHandler bufHandler) { this.bufHandler = bufHandler; @@ -135,7 +135,7 @@ public class Nio2Channel implements AsynchronousByteChannel { @Override public String toString() { -return super.toString()+":"+this.sc.toString(); +return super.toString() + ":" + sc.toString(); } @Override @@ -213,7 +213,6 @@ public class Nio2Channel implements AsynchronousByteChannel { return DONE; } - private ApplicationBufferHandler appReadBufHandler; public void setAppReadBufHandler(ApplicationBufferHandler handler) { this.appReadBufHandler = handler; diff --git a/java/org/apache/tomcat/util/net/NioChannel.java b/java/org/apache/tomcat/util/net/NioChannel.java index 9b9509f..8f97802 100644 --- a/java/org/apache/tomcat/util/net/NioChannel.java +++ b/java/org/apache/tomcat/util/net/NioChannel.java @@ -39,10 +39,10 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering protected static final ByteBuffer emptyBuf = ByteBuffer.allocate(0); +protected final SocketBufferHandler bufHandler; protected SocketChannel sc = null; protected SocketWrapperBase socketWrapper = null; -protected final SocketBufferHandler bufHandler; protected Poller poller; @@ -110,11 +110,10 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering * Close the connection. * * @param force Should the underlying socket be forcibly closed? - * * @throws IOException If closing the secure channel fails. */ public void close(boolean force) throws IOException { -if (isOpen() || force ) { +if (isOpen() || force) { close(); } } @@ -229,7 +228,7 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering @Override public String toString() { -return super.toString()+":"+this.sc.toString(); +return super.toString() + ":" + sc.toString(); } public int getOutboundRemaining() { @@ -240,7 +239,6 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering * Return true if the buffer wrote data. NO-OP for non-secure channel. * * @return Always returns {@code false} for non-secure channel - * * @throws IOException Never for non-secure channel */ public boolean flushOutbound() throws IOException { @@ -256,6 +254,7 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering * socket is removed from the poller without the socket being selected. This * results in a connection limit leak for NIO as the endpoint expects the * socket to be selected even in error conditions. + * * @throws IOException If the current thread was interrupted */ protected void checkInterruptStatus() throws IOException { @@ -264,7 +263,6 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering } } - private ApplicationBufferHandler appReadBufHandler; public void setAppReadBufHandler(ApplicationBufferHandler handler) { this.appReadBufHandler = handler; - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 496b19a Align with 9.0.x onwards 496b19a is described below commit 496b19a42fba7ae18457577da35149940591df85 Author: Mark Thomas AuthorDate: Wed Feb 16 19:48:08 2022 + Align with 9.0.x onwards --- java/org/apache/tomcat/util/net/AbstractEndpoint.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index 73cfbfb..9b9102c 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -506,8 +506,7 @@ public abstract class AbstractEndpoint { initializeConnectionLatch(); } } - -public int getMaxConnections() { return this.maxConnections; } +public int getMaxConnections() { return this.maxConnections; } /** * Return the current count of connections handled by this endpoint, if the - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new ce9e6c3 Align with 9.0.x onwards ce9e6c3 is described below commit ce9e6c321241ecfae6f86378c59e12131cf2738c Author: Mark Thomas AuthorDate: Mon Feb 7 21:10:59 2022 + Align with 9.0.x onwards --- java/org/apache/tomcat/buildutil/CheckEol.java | 48 +++--- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/java/org/apache/tomcat/buildutil/CheckEol.java b/java/org/apache/tomcat/buildutil/CheckEol.java index e33fddf..f9b9839 100644 --- a/java/org/apache/tomcat/buildutil/CheckEol.java +++ b/java/org/apache/tomcat/buildutil/CheckEol.java @@ -32,17 +32,21 @@ import org.apache.tools.ant.types.FileSet; /** * Ant task that checks that all the files in the given fileset have end-of-line - * delimiters that are appropriate for the current OS. + * delimiters that are appropriate. * * - * The goal is to check whether we have problems with svn:eol-style property - * when files are committed on one OS and then checked on another one. + * The goal is to check whether we have problems with Subversion's svn:eol-style + * property or Git's autocrlf setting when files are committed on one OS and then + * checked on another one. */ public class CheckEol extends Task { /** The files to be checked */ private final List filesets = new LinkedList<>(); +/** The line ending mode (either LF, CRLF, or null for OS specific) */ +private Mode mode; + /** * Sets the files to be checked * @@ -53,6 +57,29 @@ public class CheckEol extends Task { } /** + * Sets the line ending mode. + * + * @param mode The line ending mode (either LF or CRLF) + */ +public void setMode( String mode ) { +this.mode = Mode.valueOf( mode.toUpperCase() ); +} + +private Mode getMode() { +if ( mode != null ) { +return mode; +} else { +if ("\n".equals(System.lineSeparator())) { +return Mode.LF; +} else if ("\r\n".equals(System.lineSeparator())) { +return Mode.CRLF; +} +} + +return null; +} + +/** * Perform the check * * @throws BuildException if an error occurs during execution of @@ -61,14 +88,9 @@ public class CheckEol extends Task { @Override public void execute() throws BuildException { -Mode mode = null; -if ("\n".equals(System.lineSeparator())) { -mode = Mode.LF; -} else if ("\r\n".equals(System.lineSeparator())) { -mode = Mode.CRLF; -} else { -log("Line ends check skipped, because OS line ends setting is neither LF nor CRLF.", -Project.MSG_VERBOSE); +Mode mode = getMode(); +if ( mode == null ) { +log("Line ends check skipped, because OS line ends setting is neither LF nor CRLF.", Project.MSG_VERBOSE); return; } @@ -83,8 +105,8 @@ public class CheckEol extends Task { String[] files = ds.getIncludedFiles(); if (files.length > 0) { log("Checking line ends in " + files.length + " file(s)"); -for (int i = 0; i < files.length; i++) { -File file = new File(basedir, files[i]); +for (String filename : files) { +File file = new File(basedir, filename); log("Checking file '" + file + "' for correct line ends", Project.MSG_DEBUG); try { - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org