Sampo Niskanen created JENKINS-13896: ----------------------------------------
Summary: Exception when multiple end markers present on page Key: JENKINS-13896 URL: https://issues.jenkins-ci.org/browse/JENKINS-13896 Project: Jenkins Issue Type: Bug Components: confluence-publisher Reporter: Sampo Niskanen Assignee: Joe Hansche 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>". -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira