Properly ignore the last argument if there are an odd number.
When we saw the problem, I thought "there's no way!" because the Logger is hardened and battle-tested. But no. Since depot no longer depends on samskivert, it has reimplemented Logger and throws away a lot of the goodness that has evolved over the years. Goodness like: - warning if there are an odd number of args and the last one isn't a Throwable. - catching problems toString()ing any of the objects in the message. Let's go ride a fixie.
This commit is contained in:
@@ -45,7 +45,7 @@ public class Log
|
||||
if (args.length < 2) return message;
|
||||
StringBuilder sb = new StringBuilder(message);
|
||||
sb.append(" [");
|
||||
for (int ii = 0; ii < args.length; ii += 2) {
|
||||
for (int ii = 0, nn = args.length - (args.length % 2); ii < nn; ii += 2) {
|
||||
sb.append(args[ii]).append("=").append(args[ii+1]);
|
||||
}
|
||||
return sb.append("]").toString();
|
||||
|
||||
Reference in New Issue
Block a user