Merge branch 'stable-2.14' into stable-2.15
* stable-2.14:
Update bazlets to latest stable-2.14 to use 2.14.12 API
Allow access using Basic Authentication prefix
Update javamelody-core to 1.74.0
Prefer Javamelody's own configuration constants
Change-Id: I878592a8c317855be71302b2bc8f912efa140c97
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index fb141bc..895cfc5 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -3,8 +3,8 @@
def external_plugin_deps():
maven_jar(
name = 'javamelody-core',
- artifact = 'net.bull.javamelody:javamelody-core:1.73.1',
- sha1 = 'b848148adc6de62b7215cd27f5dab19f4963d54c',
+ artifact = 'net.bull.javamelody:javamelody-core:1.74.0',
+ sha1 = '208ab93932b32be209d264502ed153f18034500f',
)
maven_jar(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/javamelody/GerritMonitoringFilter.java b/src/main/java/com/googlesource/gerrit/plugins/javamelody/GerritMonitoringFilter.java
index b3206d7..488fe94 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/javamelody/GerritMonitoringFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/javamelody/GerritMonitoringFilter.java
@@ -36,7 +36,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.bull.javamelody.MonitoringFilter;
+import net.bull.javamelody.Parameter;
import net.bull.javamelody.internal.common.HttpParameter;
+import net.bull.javamelody.internal.common.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,10 +82,10 @@
static class JavamelodyFilter extends MonitoringFilter {
private static final String JAVAMELODY_PREFIX = "javamelody";
- private static final String HTTP_TRANSFORM_PATTERN = "http-transform-pattern";
+ private static final String HTTP_TRANSFORM_PATTERN = Parameter.HTTP_TRANSFORM_PATTERN.getCode();
private static final String GLOBAL_HTTP_TRANSFORM_PATTERN =
String.format("%s.%s", JAVAMELODY_PREFIX, HTTP_TRANSFORM_PATTERN);
- private static final String STORAGE_DIR = "storage-directory";
+ private static final String STORAGE_DIR = Parameter.STORAGE_DIRECTORY.getCode();
private static final String GLOBAL_STORAGE_DIR =
String.format("%s.%s", JAVAMELODY_PREFIX, STORAGE_DIR);
private static final String PROMETHEUS_BEARER_TOKEN = "prometheusBearerToken";
@@ -108,6 +110,7 @@
private final PluginConfig cfg;
private final Path defaultDataDir;
+ private String authenticatedMonitoringUrl;
@Inject
JavamelodyFilter(
@@ -140,6 +143,20 @@
return getMonitoringUrl(httpRequest);
}
+ @Override
+ protected String getMonitoringUrl(HttpServletRequest httpRequest) {
+ if (authenticatedMonitoringUrl == null) {
+ authenticatedMonitoringUrl =
+ httpRequest.getContextPath() + "/a" + Parameters.getMonitoringPath();
+ }
+
+ if (httpRequest.getRequestURI().equals(authenticatedMonitoringUrl)) {
+ return authenticatedMonitoringUrl;
+ }
+
+ return super.getMonitoringUrl(httpRequest);
+ }
+
private String getTransformPattern() {
return cfg.getString(HTTP_TRANSFORM_PATTERN, GERRIT_GROUPING);
}