From 6b311b7a348520450b266c99c159001bb6642867 Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Tue, 31 Mar 2015 13:28:06 -0700 Subject: [PATCH] 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. --- src/main/java/com/samskivert/depot/Log.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/samskivert/depot/Log.java b/src/main/java/com/samskivert/depot/Log.java index 1dbf828..41470fe 100644 --- a/src/main/java/com/samskivert/depot/Log.java +++ b/src/main/java/com/samskivert/depot/Log.java @@ -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();