You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gh...@apache.org on 2020/07/10 14:54:32 UTC
[felix-dev] 02/03: FELIX-6300 force autoDisableFilter=true for
avoid404DuringStartup=true
This is an automated email from the ASF dual-hosted git repository.
ghenzler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
commit 27b487177775fccf3fe9d254a244cfa824774c4f
Author: georg.henzler <ge...@netcentric.biz>
AuthorDate: Fri Jul 10 16:45:15 2020 +0200
FELIX-6300 force autoDisableFilter=true for avoid404DuringStartup=true
autoDisableFilter=false together with avoid404DuringStartup=true has the
strange effect that the 404 context that is created remains as leftover,
hence forcing autoDisableFilter=true is importnat here
---
.../felix/hc/core/impl/filter/ServiceUnavailableFilter.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java
index def5af8..3027e75 100644
--- a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java
+++ b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java
@@ -117,12 +117,12 @@ public class ServiceUnavailableFilter implements Filter {
@AttributeDefinition(name = "503 Response Text", description = "Response text for 503 responses. Value can be either the content directly or in the format '"+CLASSPATH_PREFIX+"<symbolic-bundle-id>:/path/to/file.html'. The response content type is auto-detected to either text/html or text/plain.")
String responseTextFor503() default RESPONSE_TEXT_DEFAULT;
- @AttributeDefinition(name = "Auto-disable filter", description = "If true, will automatically disable the filter once the filter continued the filter chain without 503 for the first time. Useful for server startup scenarios.")
- boolean autoDisableFilter() default false;
-
@AttributeDefinition(name = "Avoid 404", description = "If true, will automatically register a dummy servlet to ensure this filter becomes effective. Useful for server startup scenarios.")
boolean avoid404DuringStartup() default true;
+ @AttributeDefinition(name = "Auto-disable filter", description = "If true, will automatically disable the filter once the filter continued the filter chain without 503 for the first time. Useful for server startup scenarios. Becomes automatically active if avoid404DuringStartup is configured to true.")
+ boolean autoDisableFilter() default false;
+
@AttributeDefinition(name = "Filter Service Ranking", description = "The service.ranking for the filter as respected by http whiteboard.")
int service_ranking() default Integer.MAX_VALUE;
@@ -166,6 +166,10 @@ public class ServiceUnavailableFilter implements Filter {
this.includeExecutionResultInResponse = config.includeExecutionResult();
this.autoDisableFilter = config.autoDisableFilter();
this.avoid404DuringStartup = config.avoid404DuringStartup();
+ if(avoid404DuringStartup && !autoDisableFilter) {
+ LOG.debug("For avoid404DuringStartup set to true, avoid404DuringStartup is forced to true as well");
+ autoDisableFilter = true;
+ }
registerHealthCheckServiceListener();
@@ -376,7 +380,7 @@ public class ServiceUnavailableFilter implements Filter {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- send503((HttpServletResponse) resp, "Response from dynamic startup servlet");
+ send503((HttpServletResponse) resp, "Starting...");
}
}, servletProps);