diff --git a/core/impl/pom.xml b/core/impl/pom.xml
index 1caa41b5a..ef40ff459 100644
--- a/core/impl/pom.xml
+++ b/core/impl/pom.xml
@@ -32,12 +32,12 @@
INSTRUCTION
COVEREDRATIO
- 0.72
+ 0.71
BRANCH
COVEREDRATIO
- 0.59
+ 0.58
diff --git a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplication.java b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplication.java
index 78222d603..9e9719e0a 100644
--- a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplication.java
+++ b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplication.java
@@ -98,6 +98,7 @@
import java.util.stream.Stream;
import cloud.piranha.core.api.WebApplicationManager;
import static java.lang.System.Logger.Level.INFO;
+import static java.lang.System.Logger.Level.TRACE;
import java.util.Arrays;
/**
@@ -939,7 +940,9 @@ public String getVirtualServerName() {
@Override
public WebApplication initialize() {
- LOGGER.log(DEBUG, "Initializing web application at {0}", contextPath);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initializing web application at {0}", contextPath);
+ }
verifyState(SETUP, "Unable to initialize web application");
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
try {
@@ -961,9 +964,15 @@ protected void initializeFilters() {
if (status == SETUP || status == DECLARED) {
List filterNames = new ArrayList<>(filters.keySet());
filterNames.stream().map(filters::get).forEach(environment -> {
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initializing filter: {0}", environment.getFilterName());
+ }
try {
environment.initialize();
environment.getFilter().init(environment);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initialized filter: {0}", environment.getFilterName());
+ }
} catch (Throwable e) {
LOGGER.log(WARNING, () -> "Unable to initialize filter: " + environment.getFilterName(), e);
environment.setStatus(UNAVAILABLE);
@@ -978,7 +987,9 @@ protected void initializeFilters() {
protected void initializeFinish() {
if (status == SETUP || status == DECLARED) {
status = INITIALIZED;
- LOGGER.log(DEBUG, "Initialized web application at {0}", contextPath);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initialized web application at {0}", contextPath);
+ }
}
if (status == ERROR) {
LOGGER.log(WARNING, () -> "An error occurred initializing webapplication at " + contextPath);
@@ -991,6 +1002,9 @@ protected void initializeFinish() {
protected void initializeInitializers() {
boolean error = false;
for (ServletContainerInitializer initializer : initializers) {
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initializing initializer: {0}", initializer.getClass().getName());
+ }
try {
HandlesTypes annotation = initializer.getClass().getAnnotation(HandlesTypes.class);
Set> classes = Collections.emptySet();
@@ -1033,6 +1047,9 @@ protected void initializeInitializers() {
try {
source = initializer;
initializer.onStartup(classes, this);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initialized initializer: {0}", initializer.getClass().getName());
+ }
} finally {
source = null;
}
@@ -1069,10 +1086,16 @@ protected void initializeInitializers() {
}
}
- @SuppressWarnings("unchecked")
+ /**
+ * Initialize the Servlet.
+ *
+ * @param environment the Servlet environment.
+ */
protected void initializeServlet(DefaultServletEnvironment environment) {
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initializing servlet: {0}", environment.servletName);
+ }
try {
- LOGGER.log(DEBUG, "Initializing servlet: {0}", environment.servletName);
if (environment.getServlet() == null) {
Class extends Servlet> clazz = environment.getServletClass();
if (clazz == null) {
@@ -1088,7 +1111,10 @@ protected void initializeServlet(DefaultServletEnvironment environment) {
environment.setServlet(createServlet(clazz));
}
environment.getServlet().init(environment);
- LOGGER.log(DEBUG, "Initialized servlet: {0}", environment.servletName);
+
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Initialized servlet: {0}", environment.servletName);
+ }
} catch (Throwable e) {
LOGGER.log(WARNING, () -> "Unable to initialize servlet: " + environment.className, e);
@@ -1205,6 +1231,9 @@ public String removeServletMapping(String urlPattern) {
@Override
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Servicing request: {0} and response: {1}", request, response);
+ }
verifyState(SERVICING, "Unable to service request");
verifyRequestResponseTypes(request, response);
@@ -1233,6 +1262,10 @@ public void service(ServletRequest request, ServletResponse response) throws Ser
WebConnection connection = new DefaultWebConnection(webAppRequest, webAppResponse);
webAppRequest.getUpgradeHandler().init(connection);
}
+
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Serviced request: {0} and response: {1}", request, response);
+ }
}
@Override
@@ -1341,7 +1374,7 @@ public void setSessionTrackingModes(Set sessionTrackingMode
checkServicing();
getManager().getHttpSessionManager().setSessionTrackingModes(sessionTrackingModes);
}
-
+
@Override
public void setStatus(Status status) {
this.status = status;
@@ -1359,19 +1392,27 @@ public void setWebApplicationRequestMapper(WebApplicationRequestMapper webApplic
@Override
public WebApplication start() {
- LOGGER.log(DEBUG, "Starting web application at {0}", contextPath);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Starting web application at {0}", contextPath);
+ }
verifyState(INITIALIZED, "Unable to start servicing");
status = SERVICING;
- LOGGER.log(DEBUG, "Started web application at {0}", contextPath);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Started web application at {0}", contextPath);
+ }
return this;
}
@Override
public WebApplication stop() {
- LOGGER.log(DEBUG, "Stopping web application at {0}", contextPath);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Stopping web application at {0}", contextPath);
+ }
verifyState(SERVICING, "Unable to stop servicing");
status = INITIALIZED;
- LOGGER.log(DEBUG, "Stopped web application at {0}", contextPath);
+ if (LOGGER.isLoggable(TRACE)) {
+ LOGGER.log(TRACE, "Stopped web application at {0}", contextPath);
+ }
return this;
}
diff --git a/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServer.java b/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServer.java
index e1a093b17..75e2bf68b 100644
--- a/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServer.java
+++ b/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServer.java
@@ -91,7 +91,7 @@ public HttpWebApplicationServer() {
*/
public void addMapping(String servletContextName, String contextPath) {
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Adding context path: %s for: %s", contextPath, servletContextName);
+ LOGGER.log(TRACE, "Adding context path: {0} for: {1}", contextPath, servletContextName);
}
for (WebApplication webApp : webApplications.values()) {
if (webApp.getServletContextName().equals(servletContextName)) {
@@ -125,7 +125,7 @@ public void initialize() {
try {
Thread.currentThread().setContextClassLoader(webApp.getClassLoader());
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Initializing web application at: %s", webApp.getContextPath());
+ LOGGER.log(TRACE, "Initializing web application at: {0}", webApp.getContextPath());
}
webApp.initialize();
} finally {
@@ -155,7 +155,7 @@ public HttpServerProcessorEndState process(HttpServerRequest request, HttpServer
}
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Processor end state: %s", state.name());
+ LOGGER.log(TRACE, "Processor end state: {0}", state.name());
}
return state;
@@ -182,13 +182,13 @@ public void service(WebApplicationRequest request, WebApplicationResponse respon
}
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Request URI: %s", requestUri);
+ LOGGER.log(TRACE, "Request URI: {0}", requestUri);
}
WebApplication webApplication = requestMapper.findMapping(requestUri);
if (webApplication == null) {
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "No web application found for request URI: %s", requestUri);
+ LOGGER.log(TRACE, "No web application found for request URI: {0}", requestUri);
}
response.sendError(404);
return;
@@ -204,8 +204,8 @@ public void service(WebApplicationRequest request, WebApplicationResponse respon
response.setWebApplication(webApplication);
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Context Path: %s", contextPath);
- LOGGER.log(TRACE, "Servlet Path: %s", request.getServletPath());
+ LOGGER.log(TRACE, "Context Path: {0}", contextPath);
+ LOGGER.log(TRACE, "Servlet Path: {0}", request.getServletPath());
}
webApplication.service(request, response);
diff --git a/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServerRequestMapper.java b/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServerRequestMapper.java
index 498c63d0d..a3e3c7a8c 100644
--- a/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServerRequestMapper.java
+++ b/http/webapp/src/main/java/cloud/piranha/http/webapp/HttpWebApplicationServerRequestMapper.java
@@ -77,7 +77,7 @@ public Set addMapping(WebApplication webApplication, String... urlPatter
result.add(urlPattern);
} else {
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Adding url pattern: %s", urlPattern);
+ LOGGER.log(TRACE, "Adding url pattern: {0}", urlPattern);
}
this.mappings.put(urlPattern, webApplication);
}
@@ -95,7 +95,7 @@ public Set addMapping(WebApplication webApplication, String... urlPatter
@Override
public WebApplication findMapping(String path) {
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Finding web application for: %s", path);
+ LOGGER.log(TRACE, "Finding web application for: {0}", path);
}
WebApplication result = null;
String mapping = findPrefixMatch(path);
@@ -104,9 +104,9 @@ public WebApplication findMapping(String path) {
}
if (LOGGER.isLoggable(TRACE)) {
if (result != null) {
- LOGGER.log(TRACE, "Found web application at: %s", result.getContextPath());
+ LOGGER.log(TRACE, "Found web application at: {0}", result.getContextPath());
} else {
- LOGGER.log(TRACE, "Unable to find web application for: %s", path);
+ LOGGER.log(TRACE, "Unable to find web application for: {0}", path);
}
}
return result;
@@ -120,7 +120,7 @@ public WebApplication findMapping(String path) {
*/
private String findPrefixMatch(String path) {
if (LOGGER.isLoggable(TRACE)) {
- LOGGER.log(TRACE, "Find prefix for: %s", path);
+ LOGGER.log(TRACE, "Find prefix for: {0}", path);
}
String result = null;
String found;
@@ -136,9 +136,9 @@ private String findPrefixMatch(String path) {
if (LOGGER.isLoggable(TRACE)) {
if (result != null) {
- LOGGER.log(TRACE, "Found prefix: %s", result);
+ LOGGER.log(TRACE, "Found prefix: {0}", result);
} else {
- LOGGER.log(TRACE, "Unable to find prefix for: %s", path);
+ LOGGER.log(TRACE, "Unable to find prefix for: {0}", path);
}
}
return result;