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

Exception when multiple end markers present on page

    XMLWordPrintable

    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

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Joe Hansche
          Path:
          pom.xml
          src/main/java/com/myyearbook/hudson/plugins/confluence/wiki/editors/BetweenTokensEditor.java
          http://jenkins-ci.org/commit/confluence-publisher-plugin/c03fa8b25dde388ecc1e4e6bef142c90f23ec9db
          Log:
          [Fix JENKINS-13896] End marker must come after start marker.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Joe Hansche Path: pom.xml src/main/java/com/myyearbook/hudson/plugins/confluence/wiki/editors/BetweenTokensEditor.java http://jenkins-ci.org/commit/confluence-publisher-plugin/c03fa8b25dde388ecc1e4e6bef142c90f23ec9db Log: [Fix JENKINS-13896] End marker must come after start marker.
          Hide
          jhansche Joe Hansche added a comment -

          Thanks for the report and for tracking down the cause. I've committed a fix, and will be releasing an updated version shortly. You probably won't see it in your update center until tomorrow.

          Show
          jhansche Joe Hansche added a comment - Thanks for the report and for tracking down the cause. I've committed a fix, and will be releasing an updated version shortly. You probably won't see it in your update center until tomorrow.
          Hide
          jhansche Joe Hansche added a comment -

          Released as version 1.6

          Show
          jhansche Joe Hansche added a comment - Released as version 1.6

            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: