Why are we silently ignoring the last argument if someone passes in an odd number?
Instead, let's log: message [name1=value1, name2=<toString failure: ArrayIndexOutOfBoundsException>] git-svn-id: https://samskivert.googlecode.com/svn/trunk@2888 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -51,8 +51,8 @@ public class LogBuilder
|
|||||||
*/
|
*/
|
||||||
public LogBuilder append (Object... args)
|
public LogBuilder append (Object... args)
|
||||||
{
|
{
|
||||||
if (args != null && args.length > 1) {
|
if (args != null) {
|
||||||
for (int ii = 0, nn = args.length - (args.length % 2); ii < nn; ii += 2) {
|
for (int ii = 0, nn = args.length; ii < nn; ii += 2) {
|
||||||
if (_hasArgs) {
|
if (_hasArgs) {
|
||||||
_log.append(", ");
|
_log.append(", ");
|
||||||
} else {
|
} else {
|
||||||
@@ -65,7 +65,7 @@ public class LogBuilder
|
|||||||
}
|
}
|
||||||
_log.append(args[ii]).append("=");
|
_log.append(args[ii]).append("=");
|
||||||
try {
|
try {
|
||||||
Object arg = args[ii + 1];
|
Object arg = args[ii + 1]; // this may cause ArrayIndexOutOfBoundsException
|
||||||
_log.append(((arg == null) || !arg.getClass().isArray()) ? arg : arrayStr(arg));
|
_log.append(((arg == null) || !arg.getClass().isArray()) ? arg : arrayStr(arg));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
_log.append("<toString() failure: " + t + ">");
|
_log.append("<toString() failure: " + t + ">");
|
||||||
|
|||||||
Reference in New Issue
Block a user