306783 NPE for throwable
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1403 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
798c664698
commit
da9f167b31
|
@ -1,3 +1,6 @@
|
||||||
|
jetty-7.0.2.SNAPSHOT
|
||||||
|
+ 306783 - NPE in StdErrLog when Throwable is null
|
||||||
|
|
||||||
jetty-7.0.2.RC0
|
jetty-7.0.2.RC0
|
||||||
+ JSON parses NaN as null
|
+ JSON parses NaN as null
|
||||||
+ 290765 Reset input for HttpExchange retry.
|
+ 290765 Reset input for HttpExchange retry.
|
||||||
|
|
|
@ -226,18 +226,18 @@ public class StdErrLog implements Logger
|
||||||
|
|
||||||
private void format(String msg, Object arg0, Object arg1)
|
private void format(String msg, Object arg0, Object arg1)
|
||||||
{
|
{
|
||||||
int i0=msg.indexOf("{}");
|
int i0=msg==null?-1:msg.indexOf("{}");
|
||||||
int i1=i0<0?-1:msg.indexOf("{}",i0+2);
|
int i1=i0<0?-1:msg.indexOf("{}",i0+2);
|
||||||
|
|
||||||
if (i0>=0)
|
if (i0>=0)
|
||||||
{
|
{
|
||||||
format(msg.substring(0,i0));
|
format(msg.substring(0,i0));
|
||||||
format(String.valueOf(arg0));
|
format(String.valueOf(arg0==null?"null":arg0));
|
||||||
|
|
||||||
if (i1>=0)
|
if (i1>=0)
|
||||||
{
|
{
|
||||||
format(msg.substring(i0+2,i1));
|
format(msg.substring(i0+2,i1));
|
||||||
format(String.valueOf(arg1));
|
format(String.valueOf(arg1==null?"null":arg1));
|
||||||
format(msg.substring(i1+2));
|
format(msg.substring(i1+2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -268,6 +268,9 @@ public class StdErrLog implements Logger
|
||||||
|
|
||||||
private void format(String msg)
|
private void format(String msg)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
_buffer.append("null");
|
||||||
|
else
|
||||||
for (int i=0;i<msg.length();i++)
|
for (int i=0;i<msg.length();i++)
|
||||||
{
|
{
|
||||||
char c=msg.charAt(i);
|
char c=msg.charAt(i);
|
||||||
|
@ -287,15 +290,20 @@ public class StdErrLog implements Logger
|
||||||
|
|
||||||
private void format(Throwable th)
|
private void format(Throwable th)
|
||||||
{
|
{
|
||||||
_buffer.append(LN);
|
if (th == null)
|
||||||
|
_buffer.append("null");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_buffer.append('\n');
|
||||||
format(th.toString());
|
format(th.toString());
|
||||||
StackTraceElement[] elements = th.getStackTrace();
|
StackTraceElement[] elements = th.getStackTrace();
|
||||||
for (int i=0;elements!=null && i<elements.length;i++)
|
for (int i=0;elements!=null && i<elements.length;i++)
|
||||||
{
|
{
|
||||||
_buffer.append(LN).append("\tat ");
|
_buffer.append("\n\tat ");
|
||||||
format(elements[i].toString());
|
format(elements[i].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Logger getLogger(String name)
|
public Logger getLogger(String name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 2010-2010 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
|
||||||
|
package org.eclipse.jetty.util.log;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mgorovoy
|
||||||
|
* */
|
||||||
|
public class StdErrLogTest extends TestCase
|
||||||
|
{
|
||||||
|
public void testNullValues()
|
||||||
|
{
|
||||||
|
StdErrLog log = new StdErrLog();
|
||||||
|
log.setDebugEnabled(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("Testing info(msg,null,null) - {} {}",null,null);
|
||||||
|
log.info("Testing info(msg,null,null) - {}",null,null);
|
||||||
|
log.info("Testing info(msg,null,null)",null,null);
|
||||||
|
log.info(null,"- Testing","info(null,arg0,arg1)");
|
||||||
|
log.info(null,null,null);
|
||||||
|
|
||||||
|
log.debug("Testing debug(msg,null,null) - {} {}",null,null);
|
||||||
|
log.debug("Testing debug(msg,null,null) - {}",null,null);
|
||||||
|
log.debug("Testing debug(msg,null,null)",null,null);
|
||||||
|
log.debug(null,"- Testing","debug(null,arg0,arg1)");
|
||||||
|
log.debug(null,null,null);
|
||||||
|
|
||||||
|
log.debug("Testing debug(msg,null)",null);
|
||||||
|
log.debug(null,new Throwable("IGNORE::Testing debug(null,thrw)").fillInStackTrace());
|
||||||
|
|
||||||
|
log.warn("Testing warn(msg,null,null) - {} {}",null,null);
|
||||||
|
log.warn("Testing warn(msg,null,null) - {}",null,null);
|
||||||
|
log.warn("Testing warn(msg,null,null)",null,null);
|
||||||
|
log.warn(null,"- Testing","warn(msg,arg0,arg1)");
|
||||||
|
log.warn(null,null,null);
|
||||||
|
|
||||||
|
log.warn("Testing warn(msg,null)",null);
|
||||||
|
log.warn(null,new Throwable("IGNORE::Testing warn(msg,thrw)").fillInStackTrace());
|
||||||
|
}
|
||||||
|
catch (NullPointerException npe)
|
||||||
|
{
|
||||||
|
assertTrue("NullPointerException in StdErrLog.", false);
|
||||||
|
System.err.println(npe);
|
||||||
|
npe.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue