java.lang.StringIndexOutOfBoundsException

Jenkins JIRA | Sampo Niskanen | 5 years ago
  1. 0

    When using the "Replace content between start/end tokens" if the end marker exists in multiple places on the page, the first marker is selected even if it is before the start marker. This results in failure with the following stack trace: [confluence] Performing wiki edits: Replace content between start/end tokens ERROR: Publisher com.myyearbook.hudson.plugins.confluence.ConfluencePublisher aborted due to exception java.lang.StringIndexOutOfBoundsException at java.lang.AbstractStringBuilder.delete(AbstractStringBuilder.java:702) at java.lang.StringBuffer.delete(StringBuffer.java:373) at com.myyearbook.hudson.plugins.confluence.wiki.editors.BetweenTokensEditor.performEdits(BetweenTokensEditor.java:57) at com.myyearbook.hudson.plugins.confluence.wiki.editors.MarkupEditor.performReplacement(MarkupEditor.java:57) at com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.performEdits(ConfluencePublisher.java:394) at com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.performWikiReplacements(ConfluencePublisher.java:353) at com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.perform(ConfluencePublisher.java:327) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:685) at hudson.model.Build$RunnerImpl.post2(Build.java:162) at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:632) at hudson.model.Run.run(Run.java:1459) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:239) The fix for this is trivial, just search for the next end token *after* the start token. I.e. change line 45 in BetweenTokensEditor.java from final int end = content.indexOf(endMarkerToken); to final int end = content.indexOf(endMarkerToken, start); Ideally both start and end token is unique on the page, but for example when using the DIV macro to create a page portion to replace the end token is always "</ac:rich-text-body></ac:macro>".

    Jenkins JIRA | 5 years ago | Sampo Niskanen
    java.lang.StringIndexOutOfBoundsException
  2. 0

    When using the "Replace content between start/end tokens" if the end marker exists in multiple places on the page, the first marker is selected even if it is before the start marker. This results in failure with the following stack trace: [confluence] Performing wiki edits: Replace content between start/end tokens ERROR: Publisher com.myyearbook.hudson.plugins.confluence.ConfluencePublisher aborted due to exception java.lang.StringIndexOutOfBoundsException at java.lang.AbstractStringBuilder.delete(AbstractStringBuilder.java:702) at java.lang.StringBuffer.delete(StringBuffer.java:373) at com.myyearbook.hudson.plugins.confluence.wiki.editors.BetweenTokensEditor.performEdits(BetweenTokensEditor.java:57) at com.myyearbook.hudson.plugins.confluence.wiki.editors.MarkupEditor.performReplacement(MarkupEditor.java:57) at com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.performEdits(ConfluencePublisher.java:394) at com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.performWikiReplacements(ConfluencePublisher.java:353) at com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.perform(ConfluencePublisher.java:327) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:685) at hudson.model.Build$RunnerImpl.post2(Build.java:162) at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:632) at hudson.model.Run.run(Run.java:1459) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:239) The fix for this is trivial, just search for the next end token *after* the start token. I.e. change line 45 in BetweenTokensEditor.java from final int end = content.indexOf(endMarkerToken); to final int end = content.indexOf(endMarkerToken, start); Ideally both start and end token is unique on the page, but for example when using the DIV macro to create a page portion to replace the end token is always "</ac:rich-text-body></ac:macro>".

    Jenkins JIRA | 5 years ago | Sampo Niskanen
    java.lang.StringIndexOutOfBoundsException
  3. 0

    backspacing in the scala console kills it

    YouTrack | 5 years ago
    java.lang.StringIndexOutOfBoundsException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    String index out of range error when URL contains two dots

    Stack Overflow | 4 years ago | Loftx
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.StringIndexOutOfBoundsException

      No message provided

      at java.lang.AbstractStringBuilder.delete()
    2. Java RT
      StringBuffer.delete
      1. java.lang.AbstractStringBuilder.delete(AbstractStringBuilder.java:702)
      2. java.lang.StringBuffer.delete(StringBuffer.java:373)
      2 frames
    3. com.myyearbook.hudson
      ConfluencePublisher.perform
      1. com.myyearbook.hudson.plugins.confluence.wiki.editors.BetweenTokensEditor.performEdits(BetweenTokensEditor.java:57)
      2. com.myyearbook.hudson.plugins.confluence.wiki.editors.MarkupEditor.performReplacement(MarkupEditor.java:57)
      3. com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.performEdits(ConfluencePublisher.java:394)
      4. com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.performWikiReplacements(ConfluencePublisher.java:353)
      5. com.myyearbook.hudson.plugins.confluence.ConfluencePublisher.perform(ConfluencePublisher.java:327)
      5 frames
    4. Hudson
      Executor.run
      1. hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
      2. hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
      3. hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:685)
      4. hudson.model.Build$RunnerImpl.post2(Build.java:162)
      5. hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:632)
      6. hudson.model.Run.run(Run.java:1459)
      7. hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      8. hudson.model.ResourceController.execute(ResourceController.java:88)
      9. hudson.model.Executor.run(Executor.java:239)
      9 frames