Commits

Anonymous committed 9ec9029

Fixing log format to use 0-based parameterization
XW-577

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1631e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits ad9918d

Comments (0)

Files changed (3)

src/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java

      * @param e    The thrown exception.
      */
     private void logLookupFailure(String expr, Exception e) {
-        String msg = LoggerUtils.format("Caught an exception while evaluating expression '#1' against value stack", expr);
+        String msg = LoggerUtils.format("Caught an exception while evaluating expression '#0' against value stack", expr);
         if (devMode && LOG.isWarnEnabled()) {
             LOG.warn(msg, e);
             LOG.warn("NOTE: Previous warning message was issued due to devMode set to true.");

src/java/com/opensymphony/xwork2/util/logging/LoggerUtils.java

                     isArg = false;
                     if (Character.isDigit(c)) {
                         int val = Character.getNumericValue(c);
-                        if (val > 0 && val <= args.length) {
-                            sb.append(args[val-1]);
+                        if (val >= 0 && val < args.length) {
+                            sb.append(args[val]);
                             continue;
                         }
                     }

src/test/com/opensymphony/xwork2/util/logging/LoggerUtilsTest.java

         assertEquals("foo #", LoggerUtils.format("foo #"));
         assertEquals("#foo", LoggerUtils.format("#foo"));
         assertEquals("foo #1", LoggerUtils.format("foo #1"));
-        assertEquals("foo bob", LoggerUtils.format("foo #1", "bob"));
-        assertEquals("foo bob joe", LoggerUtils.format("foo #1 #2", "bob", "joe"));
-        assertEquals("foo bob joe #8", LoggerUtils.format("foo #1 #2 #8", "bob", "joe"));
+        assertEquals("foo bob", LoggerUtils.format("foo #0", "bob"));
+        assertEquals("foo bob joe", LoggerUtils.format("foo #0 #1", "bob", "joe"));
+        assertEquals("foo bob joe #8", LoggerUtils.format("foo #0 #1 #8", "bob", "joe"));
         
         assertEquals(null, LoggerUtils.format(null));
         assertEquals("", LoggerUtils.format(""));