Uploaded image for project: 'JBoss Log Manager'
  1. JBoss Log Manager
  2. LOGMGR-42

StringIndexOutOfBoundsException in exceptionFormatStep

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.4.0.Beta1
    • 1.3.1.Final
    • core
    • None

      StringIndexOutOfBoundsException is thrown when the path does not contain a jarName.
      In my case path is "/com/.../Foo.class" (from a custom classloader).

      Stacktrace:

      java.util.logging.ErrorManager: 5: Formatting error
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.charAt(String.java:686)
      	at org.jboss.logmanager.formatters.Formatters$12.renderExtended(Formatters.java:524)
      	at org.jboss.logmanager.formatters.Formatters$12.renderRaw(Formatters.java:388)
      	at org.jboss.logmanager.formatters.Formatters$JustifyingFormatStep.render(Formatters.java:150)
      	at org.jboss.logmanager.formatters.MultistepFormatter.format(MultistepFormatter.java:86)
      	at org.jboss.logmanager.ExtFormatter.format(ExtFormatter.java:35)
      	at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:49)
      	at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:76)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:290)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:298)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:298)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:298)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:298)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:298)
      	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:298)
      	at org.jboss.logmanager.Logger.logRaw(Logger.java:721)
      	at org.jboss.logmanager.Logger.log(Logger.java:539)
      

      The exception occurs here: (last line with while)

      if (jarName == null) {
      	// OK, that would have been too easy.  Next let's just grab the last piece before the class name
      	int endIdx = path.lastIndexOf(classResourceName);
      	if (endIdx != -1) {
      		do {
      			endIdx--;
      		} while (path.charAt(endIdx) == '/' || path.charAt(endIdx) == '\\' || path.charAt(endIdx) == '?');
      

      Since there is nothing before the initial /, endIdx becomes -1.

              jperkins-rhn James Perkins
              marcusk_jira Marcus Klimstra (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: