Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-13896

Exception when multiple end markers present on page

    Details

    • Similar Issues:

      Description

      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>".

        Attachments

          Activity

            People

            • Assignee:
              plaa Sampo Niskanen
              Reporter:
              plaa Sampo Niskanen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: