[tomcat] branch master updated: Fix path used by the health check valve

2020-09-01 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new 9609da1  Fix path used by the health check valve
9609da1 is described below

commit 9609da111f99ec387d64067d251669787620cff4
Author: remm 
AuthorDate: Tue Sep 1 14:29:58 2020 +0200

Fix path used by the health check valve

When not associated with a Context, it should use the full URI.
---
 .../apache/catalina/valves/HealthCheckValve.java   | 23 --
 webapps/docs/changelog.xml |  4 
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/HealthCheckValve.java 
b/java/org/apache/catalina/valves/HealthCheckValve.java
index 481e8bc..be9c487 100644
--- a/java/org/apache/catalina/valves/HealthCheckValve.java
+++ b/java/org/apache/catalina/valves/HealthCheckValve.java
@@ -20,6 +20,8 @@ import java.io.IOException;
 
 import jakarta.servlet.ServletException;
 
+import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.tomcat.util.buf.MessageBytes;
@@ -35,8 +37,14 @@ public class HealthCheckValve extends ValveBase {
 "  \"status\": \"UP\",\n" +
 "  \"checks\": []\n" +
 "}";
+
 private String path = "/health";
 
+/**
+ * Will be set to true if the valve is associated with a context.
+ */
+protected boolean context = false;
+
 public HealthCheckValve() {
 super(true);
 }
@@ -50,10 +58,21 @@ public class HealthCheckValve extends ValveBase {
 }
 
 @Override
+protected synchronized void startInternal() throws LifecycleException {
+super.startInternal();
+if (getContainer() instanceof Context) {
+context = true;
+} else {
+context = false;
+}
+}
+
+@Override
 public void invoke(Request request, Response response)
 throws IOException, ServletException {
-MessageBytes requestPathMB = request.getRequestPathMB();
-if (requestPathMB.equals(path)) {
+MessageBytes urlMB =
+context ? request.getRequestPathMB() : 
request.getDecodedRequestURIMB();
+if (urlMB.equals(path)) {
 response.setContentType("application/json");
 response.getOutputStream().print(UP);
 } else {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index dae52f6..d3327d7 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -101,6 +101,10 @@
 Use the correct method to calculate session idle time in
 PersistentValve. (kfujino)
   
+  
+Fix path used by the health check valve when it is not associated with
+a Context. (remm)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch master updated: Fix path validation when docBase="/"

2020-08-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new 14cc26c  Fix path validation when docBase="/"
14cc26c is described below

commit 14cc26c247f95a14912268ebc26abe618bd7511c
Author: Mark Thomas 
AuthorDate: Tue Aug 25 10:01:50 2020 +0100

Fix path validation when docBase="/"
---
 .../org/apache/catalina/webresources/AbstractFileResourceSet.java | 8 
 webapps/docs/changelog.xml| 5 +
 2 files changed, 13 insertions(+)

diff --git a/java/org/apache/catalina/webresources/AbstractFileResourceSet.java 
b/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
index b79f88b..c799341 100644
--- a/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
+++ b/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
@@ -212,6 +212,14 @@ public abstract class AbstractFileResourceSet extends 
AbstractResourceSet {
 } catch (IOException e) {
 throw new IllegalArgumentException(e);
 }
+
+// Need to handle mapping of the file system root as a special case
+if ("/".equals(this.absoluteBase)) {
+this.absoluteBase = "";
+}
+if ("/".equals(this.canonicalBase)) {
+this.canonicalBase = "";
+}
 }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 987fb3b..9931b8a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -88,6 +88,11 @@
 associated code for clarity.
 Based on a patch provided by Milo van der Zee. (markt)
   
+  
+Correct the path vaidation to allow the use of the file system root for
+the docBase attribute of a Context. Note that
+such a configuration should be used with caution. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch master updated: Fix path

2020-06-29 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new 19c191e  Fix path
19c191e is described below

commit 19c191ea029089c62ece640de27adb2fa18d5769
Author: remm 
AuthorDate: Mon Jun 29 22:44:28 2020 +0200

Fix path
---
 webapps/docs/graal.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/webapps/docs/graal.xml b/webapps/docs/graal.xml
index b89dc1d..aaafbd2 100644
--- a/webapps/docs/graal.xml
+++ b/webapps/docs/graal.xml
@@ -64,9 +64,9 @@
 cd $JAVA_HOME/bin
 ./gu install native-image
Mandrel already includes the Native Image tool ready to use, so this
-   step can be skipped. Only JAVA_HOME must be set to the mandrelJDK folder,
-   such as:
-   export 
JAVA_HOME=/absolute...path...to/mandrel-javaXX-platform-x.x.x.x
+   step can be skipped. Only JAVA_HOME must be set to the folder which
+   contains the bin folder with the JVM binaries, such as:
+   export 
JAVA_HOME=/absolute...path...to/mandrel-javaXX-platform-x.x.x.x/mandrelJDK
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org