Skip to content

Commit

Permalink
Issue #4996 Regularize logging
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Aug 5, 2020
1 parent 062878f commit 6ffcf40
Show file tree
Hide file tree
Showing 76 changed files with 178 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ public void handleField(Class<?> clazz, Field field)
//JavaEE Spec 5.2.3: Field cannot be static
if (Modifier.isStatic(field.getModifiers()))
{
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + field.getName() + ": cannot be static");
LOG.warn("Skipping Resource annotation on {}.{}: cannot be static", clazz.getName(), field.getName());
return;
}

//JavaEE Spec 5.2.3: Field cannot be final
if (Modifier.isFinal(field.getModifiers()))
{
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + field.getName() + ": cannot be final");
LOG.warn("Skipping Resource annotation on {}.{}: cannot be final", clazz.getName(), field.getName());
return;
}

Expand Down Expand Up @@ -243,27 +243,27 @@ public void handleMethod(Class<?> clazz, Method method)
//JavaEE Spec 5.2.3: Method cannot be static
if (Modifier.isStatic(method.getModifiers()))
{
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": cannot be static");
LOG.warn("Skipping Resource annotation on {}.{}: cannot be static", clazz.getName(), method.getName());
return;
}

// Check it is a valid javabean: must be void return type, the name must start with "set" and it must have
// only 1 parameter
if (!method.getName().startsWith("set"))
{
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": invalid java bean, does not start with 'set'");
LOG.warn("Skipping Resource annotation on {}.{}: invalid java bean, does not start with 'set'", clazz.getName(), method.getName());
return;
}

if (method.getParameterCount() != 1)
{
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": invalid java bean, not single argument to method");
LOG.warn("Skipping Resource annotation on {}.{}: invalid java bean, not single argument to method", clazz.getName(), method.getName());
return;
}

if (Void.TYPE != method.getReturnType())
{
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": invalid java bean, not void");
LOG.warn("Skipping Resource annotation on {}.{}: invalid java bean, not void", clazz.getName(), method.getName());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void doHandle(Class<?> clazz)
Resource[] resArray = resources.value();
if (resArray == null || resArray.length == 0)
{
LOG.warn("Skipping empty or incorrect Resources annotation on " + clazz.getName());
LOG.warn("Skipping empty or incorrect Resources annotation on {}", clazz.getName());
return;
}

Expand All @@ -63,7 +63,8 @@ public void doHandle(Class<?> clazz)

if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name, mappedName))
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name, mappedName))
LOG.warn("Skipping Resources(Resource) annotation on " + clazz.getName() + " for name " + name + ": No resource bound at " + (mappedName == null ? name : mappedName));
LOG.warn("Skipping Resources(Resource) annotation on {} for name {}: no resource bound at {}",
clazz.getName(), name, (mappedName == null ? name : mappedName));
}
catch (NamingException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ public void doHandle(Class clazz)
}
}
else
LOG.warn("Bad value for @RunAs annotation on class " + clazz.getName());
LOG.warn("Bad value for @RunAs annotation on class {}", clazz.getName());
}
}

public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation)
{
LOG.warn("@RunAs annotation not applicable for fields: " + className + "." + fieldName);
LOG.warn("@RunAs annotation not applicable for fields: {}.{}", className, fieldName);
}

public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation)
{
LOG.warn("@RunAs annotation ignored on method: " + className + "." + methodName + " " + signature);
LOG.warn("@RunAs annotation ignored on method: {}.{} {}", className, methodName, signature);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void doHandle(Class clazz)

if (constraintsExist(servletMappings, constraintMappings))
{
LOG.warn("Constraints already defined for " + clazz.getName() + ", skipping ServletSecurity annotation");
LOG.warn("Constraints already defined for {}, skipping ServletSecurity annotation", clazz.getName());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public void apply()
Class clazz = getTargetClass();
if (clazz == null)
{
LOG.warn(_className + " cannot be loaded");
LOG.warn("{} cannot be loaded", _className);
return;
}

//Servlet Spec 8.1.2
if (!Filter.class.isAssignableFrom(clazz))
{
LOG.warn(clazz.getName() + " is not assignable from javax.servlet.Filter");
LOG.warn("{} is not assignable from javax.servlet.Filter", clazz.getName());
return;
}
MetaData metaData = _context.getMetaData();
Expand All @@ -78,7 +78,7 @@ public void apply()

if (filterAnnotation.value().length > 0 && filterAnnotation.urlPatterns().length > 0)
{
LOG.warn(clazz.getName() + " defines both @WebFilter.value and @WebFilter.urlPatterns");
LOG.warn("{} defines both @WebFilter.value and @WebFilter.urlPatterns", clazz.getName());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public void handle(FieldInfo info, String annotationName)
{
if (annotationName == null || !"javax.servlet.annotation.WebFilter".equals(annotationName))
return;
LOG.warn("@WebFilter not applicable for fields: " + info.getClassInfo().getClassName() + "." + info.getFieldName());
LOG.warn("@WebFilter not applicable for fields: {}.{}", info.getClassInfo().getClassName(), info.getFieldName());
}

@Override
public void handle(MethodInfo info, String annotationName)
{
if (annotationName == null || !"javax.servlet.annotation.WebFilter".equals(annotationName))
return;
LOG.warn("@WebFilter not applicable for methods: " + info.getClassInfo().getClassName() + "." + info.getMethodName() + " " + info.getSignature());
LOG.warn("@WebFilter not applicable for methods: {}.{} {}", info.getClassInfo().getClassName(), info.getMethodName(), info.getSignature());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void apply()

if (clazz == null)
{
LOG.warn(_className + " cannot be loaded");
LOG.warn("{} cannot be loaded", _className);
return;
}

Expand All @@ -84,7 +84,7 @@ public void apply()
}
}
else
LOG.warn(clazz.getName() + " does not implement one of the servlet listener interfaces");
LOG.warn("{} does not implement one of the servlet listener interfaces", clazz.getName());
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public void handle(FieldInfo info, String annotationName)
{
if (annotationName == null || !"javax.servlet.annotation.WebListener".equals(annotationName))
return;
LOG.warn("@WebListener is not applicable to fields: " + info.getClassInfo().getClassName() + "." + info.getFieldName());
LOG.warn("@WebListener is not applicable to fields: {}.{}", info.getClassInfo().getClassName(), info.getFieldName());
}

@Override
public void handle(MethodInfo info, String annotationName)
{
if (annotationName == null || !"javax.servlet.annotation.WebListener".equals(annotationName))
return;
LOG.warn("@WebListener is not applicable to methods: " + info.getClassInfo().getClassName() + "." + info.getMethodName() + " " + info.getSignature());
LOG.warn("@WebListener is not applicable to methods: {}.{} {}", info.getClassInfo().getClassName(), info.getMethodName(), info.getSignature());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ public void apply()

if (clazz == null)
{
LOG.warn(_className + " cannot be loaded");
LOG.warn("{} cannot be loaded", _className);
return;
}

//Servlet Spec 8.1.1
if (!HttpServlet.class.isAssignableFrom(clazz))
{
LOG.warn(clazz.getName() + " is not assignable from javax.servlet.http.HttpServlet");
LOG.warn("{} is not assignable from javax.servlet.http.HttpServlet", clazz.getName());
return;
}

WebServlet annotation = (WebServlet)clazz.getAnnotation(WebServlet.class);

if (annotation.urlPatterns().length > 0 && annotation.value().length > 0)
{
LOG.warn(clazz.getName() + " defines both @WebServlet.value and @WebServlet.urlPatterns");
LOG.warn("{} defines both @WebServlet.value and @WebServlet.urlPatterns", clazz.getName());
return;
}

Expand All @@ -90,7 +90,7 @@ public void apply()

if (urlPatterns.length == 0)
{
LOG.warn(clazz.getName() + " defines neither @WebServlet.value nor @WebServlet.urlPatterns");
LOG.warn("{} defines neither @WebServlet.value nor @WebServlet.urlPatterns", clazz.getName());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public void onStartup(Set<Class<?>> c, ServletContext ctx)
}

context.setAttribute(CDI_INTEGRATION_ATTRIBUTE, mode);
LOG.info(mode + " enabled in " + ctx);
LOG.info("{} enabled in {}", mode, ctx);
}
catch (UnsupportedOperationException | ClassNotFoundException e)
{
if (LOG.isDebugEnabled())
LOG.debug("CDI not found in " + ctx, e);
LOG.debug("CDI not found in {}", ctx, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public <T> T decorate(T o)
}
catch (Throwable th)
{
LOG.warn("Unable to decorate " + o, th);
LOG.warn("Unable to decorate {}", o, th);
}
return o;
}
Expand All @@ -134,7 +134,7 @@ public void destroy(Object o)
}
catch (Throwable th)
{
LOG.warn("Unable to destroy " + o, th);
LOG.warn("Unable to destroy {}", o, th);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private void requestAppGoal(AppEntry appentry, String nodeName)
}
catch (Throwable t)
{
LOG.warn("Unable to reach node goal: " + nodeName, t);
LOG.warn("Unable to reach node goal: {}", nodeName, t);

// migrate to FAILED node
Node failed = _lifecycle.getNodeByName(AppLifeCycle.FAILED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void processBinding(Node node, App app) throws Exception
}
else
{
LOG.info("Binding: Unable to locate global webapp context settings: " + _jettyXml);
LOG.info("Binding: Unable to locate global webapp context settings: {}", _jettyXml);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected void doStart() throws Exception
if (resource.exists() && resource.getFile().canRead())
files.add(resource.getFile());
else
LOG.warn("Does not exist: " + resource);
LOG.warn("Does not exist: {}", resource);
}

_scanner = new Scanner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static HttpCompliance from(String spec)
Violation section = Violation.valueOf(element);
if (section == null)
{
LOG.warn("Unknown section '" + element + "' in HttpCompliance spec: " + spec);
LOG.warn("Unknown section '{}' in HttpCompliance spec: {}", element, spec);
continue;
}
if (exclude)
Expand Down
10 changes: 5 additions & 5 deletions jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ else if (_responseHandler != null)
// count this white space as a header byte to avoid DOS
if (_maxHeaderBytes > 0 && ++_headerBytes > _maxHeaderBytes)
{
LOG.warn("padding is too large >" + _maxHeaderBytes);
LOG.warn("padding is too large >{}", _maxHeaderBytes);
throw new BadMessageException(HttpStatus.BAD_REQUEST_400);
}
}
Expand Down Expand Up @@ -584,15 +584,15 @@ private boolean parseLine(ByteBuffer buffer)
{
if (_state == State.URI)
{
LOG.warn("URI is too large >" + _maxHeaderBytes);
LOG.warn("URI is too large >{}", _maxHeaderBytes);
throw new BadMessageException(HttpStatus.URI_TOO_LONG_414);
}
else
{
if (_requestHandler != null)
LOG.warn("request is too large >" + _maxHeaderBytes);
LOG.warn("request is too large >{}", _maxHeaderBytes);
else
LOG.warn("response is too large >" + _maxHeaderBytes);
LOG.warn("response is too large >{}", _maxHeaderBytes);
throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431);
}
}
Expand Down Expand Up @@ -702,7 +702,7 @@ private boolean parseLine(ByteBuffer buffer)

if (_maxHeaderBytes > 0 && ++_headerBytes > _maxHeaderBytes)
{
LOG.warn("URI is too large >" + _maxHeaderBytes);
LOG.warn("URI is too large >{}", _maxHeaderBytes);
throw new BadMessageException(HttpStatus.URI_TOO_LONG_414);
}
_uri.append(array, p - 1, len + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class PreEncodedHttpField extends HttpField
if (__encoders[i] == null)
__encoders[i] = e;
else
LOG.warn("multiple PreEncoders for " + e.getHttpVersion());
LOG.warn("multiple PreEncoders for {}", e.getHttpVersion());
}

// Always support HTTP1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ public long getLeakedResources()

protected void leaked(LeakDetector<ByteBuffer>.LeakInfo leakInfo)
{
LOG.warn("ByteBuffer " + leakInfo.getResourceDescription() + " leaked at:", leakInfo.getStackFrames());
LOG.warn("ByteBuffer {} leaked at: {}", leakInfo.getResourceDescription(), leakInfo.getStackFrames());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,10 @@ private boolean select()
}
else
{
LOG.warn(x.toString());
if (LOG.isDebugEnabled())
LOG.debug("select() failure", x);
LOG.warn("select() failure", x);
else
LOG.warn(x.toString());

This comment has been minimized.

Copy link
@joakime

joakime Aug 5, 2020

Contributor

IMO, this should keep the description "select() failure"

}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ public void connectionOpened(Connection connection, Object context)
catch (Throwable x)
{
if (isRunning())
LOG.warn("Exception while notifying connection " + connection, x);
LOG.warn("Exception while notifying connection {}", connection, x);
else
LOG.debug("Exception while notifying connection " + connection, x);
LOG.debug("Exception while notifying connection {}", connection, x);

This comment has been minimized.

Copy link
@joakime

joakime Aug 5, 2020

Contributor

This could be simplified (in Jetty 10) as ...

LOG.makeLoggingEventBuilder(isRunning()?Level.WARN:Level.DEBUG).log("Exception while notifying connection {}", connection, x);
throw x;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public boolean bindingLogin(String username, Object password) throws LoginExcept

String userDn = searchResult.getNameInNamespace();

LOG.info("Attempting authentication: " + userDn);
LOG.info("Attempting authentication: {}", userDn);

Hashtable<Object, Object> environment = getEnvironment();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public void beanAdded(Container parent, Object obj)
}
catch (Throwable x)
{
LOG.warn("bean: " + obj, x);
LOG.warn("bean: {}", obj, x);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ public void copyTo(File directory) throws IOException
{
String entryName = entry.getName();

LOG.debug("Looking at " + entryName);
LOG.debug("Looking at {}", entryName);
String dotCheck = StringUtil.replace(entryName, '\\', '/');
dotCheck = URIUtil.canonicalPath(dotCheck);
if (dotCheck == null)
{
LOG.info("Invalid entry: " + entryName);
LOG.info("Invalid entry: {}", entryName);
continue;
}

Expand Down
Loading

0 comments on commit 6ffcf40

Please sign in to comment.