Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IndexOutOfBoundsException with v0.6.0 #139

Closed
manchot0 opened this issue Nov 21, 2018 · 15 comments · Fixed by #143
Closed

java.lang.IndexOutOfBoundsException with v0.6.0 #139

manchot0 opened this issue Nov 21, 2018 · 15 comments · Fixed by #143

Comments

@manchot0
Copy link

Hi, since version 0.6.0 i have the following error on my pipeline when running a build :

java.lang.IndexOutOfBoundsException
	at hudson.MarkupText.rangeCheck(MarkupText.java:276)
	at hudson.MarkupText.addMarkup(MarkupText.java:270)
	at hudson.plugins.ansicolor.ColorConsoleAnnotator$1EmitterImpl.emitHtml(ColorConsoleAnnotator.java:74)
	at hudson.plugins.ansicolor.AnsiAttributeElement.emitClose(AnsiAttributeElement.java:42)
	at hudson.plugins.ansicolor.AnsiHtmlOutputStream.closeOpenTags(AnsiHtmlOutputStream.java:107)
	at hudson.plugins.ansicolor.AnsiHtmlOutputStream.processAttributeRest(AnsiHtmlOutputStream.java:542)
	at hudson.plugins.ansicolor.AnsiOutputStream.processEscapeCommand(AnsiOutputStream.java:358)
	at hudson.plugins.ansicolor.AnsiOutputStream.write(AnsiOutputStream.java:138)
	at hudson.plugins.ansicolor.AnsiHtmlOutputStream.write(AnsiHtmlOutputStream.java:220)
	at org.apache.commons.io.output.ProxyOutputStream.write(ProxyOutputStream.java:55)
	at hudson.plugins.ansicolor.ColorConsoleAnnotator.annotate(ColorConsoleAnnotator.java:91)
	at hudson.console.ConsoleAnnotator$ConsoleAnnotatorAggregator.annotate(ConsoleAnnotator.java:108)
	at hudson.console.ConsoleAnnotationOutputStream.eol(ConsoleAnnotationOutputStream.java:148)
	at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)
	at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)
	at java.io.FilterOutputStream.write(FilterOutputStream.java:77)
	at org.jenkinsci.plugins.workflow.log.FileLogStorage$1$1.write(FileLogStorage.java:238)
	at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
	at org.apache.commons.io.output.ProxyOutputStream.write(ProxyOutputStream.java:90)
	at org.kohsuke.stapler.framework.io.LargeText$HeadMark.moveTo(LargeText.java:314)
	at org.kohsuke.stapler.framework.io.LargeText.writeLogTo(LargeText.java:229)
	at hudson.console.AnnotatedLargeText.writeRawLogTo(AnnotatedLargeText.java:163)
	at org.jenkinsci.plugins.workflow.log.FileLogStorage$1.writeHtmlTo(FileLogStorage.java:203)
	at hudson.console.AnnotatedLargeText.writeLogTo(AnnotatedLargeText.java:144)
	at org.kohsuke.stapler.framework.io.LargeText.doProgressText(LargeText.java:264)
	at hudson.console.AnnotatedLargeText.doProgressiveHtml(AnnotatedLargeText.java:92)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
	at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:130)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
Caused: javax.servlet.ServletException
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:789)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$3.doDispatch(MetaClass.java:212)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:384)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:253)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:253)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:253)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:668)
	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
	at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:243)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:99)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:503)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:745)

The pipeline still kept going but there is no more output on the console.
the error seems to always appear at the same step :

def mavenVersion(){
ansiColor('xterm') {
     echo "\033[94;1m[ INFO ] Récupération du numéro de version de l'application\033[0m"
}
     env.APP_VERSION = sh script : 'grep "<version>" pom.xml | head -n 1 | grep -om1 "[0-9.]\\+"',returnStdout: true
}

but there is two output in colors displayed before like this one :

def CleanAledaDependency(){
ansiColor('xterm') {
    echo "\033[94;1m[ INFO ] Nettoyage des dépendances  dans le cache maven et gradle\033[0m"
}
    sh 'rm -rf /home/jenkins/.m2/repository/xxx/* & rm -rf /home/jenkins/.gradle/caches/modules-2/files-2.1/xxx/*'
}

I am on Jenkins 2.152 with the multibranch pipeline. I have reverted back to the 0.5.3 version of the plugin.

@manchot0 manchot0 changed the title java.lang.IndexOutOfBoundsException error java.lang.IndexOutOfBoundsException with v0.6.0 Nov 21, 2018
@navrkald
Copy link

I had same issue and can confirm downgrade to 0.5.3 helped!

@Dukecz
Copy link

Dukecz commented Nov 29, 2018

@aaratushnyak
Copy link

I had same issue

@igiu1988
Copy link

igiu1988 commented Dec 4, 2018

i had same issue 0.6.0. 0.5.2 is good

@dblock
Copy link
Member

dblock commented Dec 4, 2018

cc: @dwnusbaum @jglick who contributed a lot of changes there

Anyone please write a test and a fix for this?

@dwnusbaum
Copy link
Member

I think the code is broken for any annotated line with more than 1 multi-byte character such as é (I'm not yet sure why there is one character of leeway, maybe MarkupText allows insertions at the end of the text). We count bytes as we process input and use that to produce offsets for where to insert HTML markup, but the HTML markup is a Java-level string, and so é gets counted as 2 bytes, but at the Java level it is a single character, so our offset calculations are wrong and we overshoot the end of the string in some cases.

@dwnusbaum
Copy link
Member

dwnusbaum commented Dec 4, 2018

I think this would be fixed by a2a74eb + 7d8b58d + c1d7aab, which I've pushed into #137. I will try to separate those commits from the other bug fixes in that PR sometime today so it can be merged/released independently.

EDIT: Done now in #143.

@kraduk
Copy link

kraduk commented Dec 12, 2018

I was also getting this issue when used in conjunction with the ansible playbook. Rolling back the ansicolour to 0.5.2 does indeed fix the issue

@jkugler
Copy link

jkugler commented Dec 14, 2018

@navrkald and @kraduk How do I roll back? The releases seem to be all source, no binaries. I don't have a way to compile plugins right now, and I don't see a way to specify the version in the Jenkins Plugin Installer. Pointers/docs/etc welcome.

@dblock
Copy link
Member

dblock commented Dec 16, 2018

Sorry for the hassle everyone. I have't been using Jenkins much so I am going to leave the proposed fixes to @jglick and @dwnusbaum to sort out, merge and release. Will jump in if one is unavailable or something like that this week.

@dwnusbaum
Copy link
Member

A fix for this issue was just released in ansicolor 0.6.1.

@RishabhTayal
Copy link

I can confirm this issue is fixed. I was having this issue in 0.6.0, after upgrading to 0.6.1 it's fixed. 💯

@shreknitin89
Copy link

shreknitin89 commented May 29, 2019

@dwnusbaum This is still happening on 0.6.2. After the build is finished sometimes we get the complete logs but in some cases gets the truncated logs.

While the build is running at some point in the logs we get the same exception.

java.lang.IndexOutOfBoundsException at hudson.MarkupText.addMarkup(MarkupText.java:260) at hudson.plugins.ansicolor.ColorConsoleAnnotator$1EmitterImpl.emitHtml(ColorConsoleAnnotator.java:100) at hudson.plugins.ansicolor.AnsiAttributeElement.emitOpen(AnsiAttributeElement.java:47) at hudson.plugins.ansicolor.AnsiHtmlOutputStream.openTag(AnsiHtmlOutputStream.java:119)

@dwnusbaum
Copy link
Member

@shreknitin89 The exception might be the same, but your stack trace looks distinct from the one reported in this ticket. I would open a new issue, preferably including a minimal subset of your logs that reproduces the problem.

@shreknitin89
Copy link

Ok @dwnusbaum. I opened #158 for the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.