From: kkolinko Date: Tue, 2 Nov 2010 22:04:44 +0000 (+0000) Subject: Improve handling of nulls in StandardEngine.logAccess() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a86aa7f3bcd1c7036a5cd505a0d7e06b15515f1f;p=tomcat7.0 Improve handling of nulls in StandardEngine.logAccess() This takes care of the case when findChild(getDefaultHost()) returns null. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1030253 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/core/StandardEngine.java b/java/org/apache/catalina/core/StandardEngine.java index 8eaac5cd5..ae9c95803 100644 --- a/java/org/apache/catalina/core/StandardEngine.java +++ b/java/org/apache/catalina/core/StandardEngine.java @@ -313,26 +313,27 @@ public class StandardEngine extends ContainerBase implements Engine { } if (!logged && useDefault) { - Host host = null; if (defaultAccessLog == null) { // If we reached this point, this Engine can't have an AccessLog // Look in the defaultHost - host = (Host) findChild(getDefaultHost()); - defaultAccessLog = host.getAccessLog(); - - if (defaultAccessLog == null) { - // Try the ROOT context of default host - Context context = (Context) host.findChild(""); - if (context != null) { - defaultAccessLog = context.getAccessLog(); - } + Host host = (Host) findChild(getDefaultHost()); + if (host != null) { + defaultAccessLog = host.getAccessLog(); if (defaultAccessLog == null) { - defaultAccessLog = new NoopAccessLog(); + // Try the ROOT context of default host + Context context = (Context) host.findChild(""); + if (context != null) { + defaultAccessLog = context.getAccessLog(); + } } } + + if (defaultAccessLog == null) { + defaultAccessLog = new NoopAccessLog(); + } } - + defaultAccessLog.log(request, response, time); } }