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

raise java.util.ConcurrentModificationException #77

Open
wuhuizuo opened this issue May 16, 2018 · 2 comments
Open

raise java.util.ConcurrentModificationException #77

wuhuizuo opened this issue May 16, 2018 · 2 comments

Comments

@wuhuizuo
Copy link

sa.approveScript(pending.getHash());

my env:

  • Jenkins ver. 2.107.1

my script:

import org.jenkinsci.plugins.scriptsecurity.scripts.*
  
def method = "something"
def signature = "something"

ScriptApproval sa = ScriptApproval.get();

//list pending approvals
for (ScriptApproval.PendingScript pending : sa.getPendingScripts()) {
        println "Pending Approved : " + pending.script
}

for (ScriptApproval.PendingSignature pending : sa.getPendingSignatures()) {
        println "Pending Approved : " + pending.signature
}  

// approve scripts
for (ScriptApproval.PendingScript pending : sa.getPendingScripts()) {
       	sa.approveScript(pending.getHash());
     	println "Approved : " + pending.script      
}

// approbve signatures
for (ScriptApproval.PendingSignature pending : sa.getPendingSignatures()) {
       	sa.approveSignature(pending.signature);
     	println "Approved : " + pending.signature      
}

exec output:

Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent java.util.Map
Pending Approved : staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.Utils createStepsBlock groovy.lang.Closure
Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.Stage java.lang.String org.jenkinsci.plugins.pipeline.modeldefinition.model.StepsBlock org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent org.jenkinsci.plugins.pipeline.modeldefinition.model.PostStage org.jenkinsci.plugins.pipeline.modeldefinition.model.StageConditionals org.jenkinsci.plugins.pipeline.modeldefinition.model.Tools org.jenkinsci.plugins.pipeline.modeldefinition.model.Environment boolean org.jenkinsci.plugins.pipeline.modeldefinition.model.Stages org.jenkinsci.plugins.pipeline.modeldefinition.model.StageOptions org.jenkinsci.plugins.pipeline.modeldefinition.model.StageInput
Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.Stages java.util.List
Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.Root org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent org.jenkinsci.plugins.pipeline.modeldefinition.model.Stages org.jenkinsci.plugins.pipeline.modeldefinition.model.PostBuild org.jenkinsci.plugins.pipeline.modeldefinition.model.Environment org.jenkinsci.plugins.pipeline.modeldefinition.model.Tools org.jenkinsci.plugins.pipeline.modeldefinition.model.Options org.jenkinsci.plugins.pipeline.modeldefinition.model.Triggers org.jenkinsci.plugins.pipeline.modeldefinition.model.Parameters org.jenkinsci.plugins.pipeline.modeldefinition.model.Libraries java.lang.String
Pending Approved : method org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager addShortText java.lang.String
Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.PostStage java.util.Map
Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.StageConditionals groovy.lang.Closure java.lang.Boolean
Pending Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.PostBuild java.util.Map
Pending Approved : staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.when.impl.ExpressionConditional$DescriptorImpl instanceFromClosure groovy.lang.Closure
Pending Approved : staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods findAll java.lang.String java.util.regex.Pattern groovy.lang.Closure
Pending Approved : staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods replaceAll java.lang.String java.util.regex.Pattern java.lang.String
Pending Approved : method org.jenkinsci.plugins.workflow.cps.CpsClosure2 println java.lang.Object
Pending Approved : method org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager addShortText java.lang.String java.lang.String java.lang.String java.lang.String java.lang.String
Pending Approved : method groovy.lang.GroovyObject getProperty java.lang.String
Pending Approved : staticMethod org.jenkinsci.plugins.workflow.cps.Safepoint safepoint
Pending Approved : method org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager addInfoBadge java.lang.String
Approved : new org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent java.util.Map
java.util.ConcurrentModificationException
	at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:719)
	at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:742)
	at Script1.run(Script1.groovy:24)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:142)
	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:114)
	at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
	at hudson.util.RemotingDiagnostics.executeGroovy(RemotingDiagnostics.java:111)
	at jenkins.model.Jenkins._doScript(Jenkins.java:4331)
	at jenkins.model.Jenkins.doScript(Jenkins.java:4302)
	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:129)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
	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:841)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
	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:1637)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	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:190)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
	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:166)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:564)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
	at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
	at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
	at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
@FrankJian
Copy link

maybe you can use "sa.getPendingScripts().clone()" and "sa.getPendingSignatures().clone()" in the loop to avoid the exception

@sgsollie
Copy link

sgsollie commented Jun 26, 2019

Ran into this issue, can confirm appending .clone() to sa.getPendingSignatures() works here.

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

No branches or pull requests

3 participants