Skip to content

Commit d781a3b

Browse files
authored
Merge branch 'master' into logging-exMTL
2 parents 5a50a57 + 43db123 commit d781a3b

File tree

16 files changed

+100
-82
lines changed

16 files changed

+100
-82
lines changed

dgm-builder/src/main/java/com/cloudbees/groovy/cps/tool/Translator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private String mangledName(ExecutableElement e) {
169169
*/
170170
public void translate(String fqcn, String outfqcn, String sourceJarName) throws JClassAlreadyExistsException {
171171
final JDefinedClass $output = codeModel._class(outfqcn);
172-
$output.annotate(Generated.class).param("value", Translator.class.getName()).param("date", new Date().toString()).param("comments", "based on " + sourceJarName);
172+
$output.annotate(Generated.class).param("value", Translator.class.getName()).param("comments", "based on " + sourceJarName);
173173
$output.annotate(SuppressWarnings.class).param("value", "rawtypes");
174174
$output.constructor(JMod.PRIVATE);
175175

lib/src/main/java/com/cloudbees/groovy/cps/Continuable.java

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
*/
2424
public class Continuable implements Serializable {
2525

26+
/**
27+
* Users of this library must pass (at least) these to {@link GroovyCategorySupport#use(List, Closure)} during all operations.
28+
*/
2629
@SuppressWarnings("rawtypes")
2730
public static final List<Class> categories = List.of(
2831
CpsDefaultGroovyMethods.class,
@@ -133,31 +136,21 @@ public Object runByThrow(Throwable arg) throws InvocationTargetException {
133136
return run0(new Outcome(null,arg)).wrapReplay();
134137
}
135138

136-
@Deprecated
137-
public Outcome run0(final Outcome cn) {
138-
return run0(cn, categories);
139-
}
140-
141139
/**
142140
* Resumes this program by either returning the value from {@link Continuable#suspend(Object)} or
143141
* throwing an exception
144142
*/
145-
public Outcome run0(final Outcome cn, List<Class> categories) {
146-
return GroovyCategorySupport.use(categories, new Closure<>(null) {
147-
@Override
148-
public Outcome call() {
149-
Next n = cn.resumeFrom(e,k);
150-
151-
while(n.yield==null) {
152-
n = n.step();
153-
}
154-
155-
e = n.e;
156-
k = n.k;
157-
158-
return n.yield;
159-
}
160-
});
143+
public Outcome run0(final Outcome cn) {
144+
Next n = cn.resumeFrom(e,k);
145+
146+
while(n.yield==null) {
147+
n = n.step();
148+
}
149+
150+
e = n.e;
151+
k = n.k;
152+
153+
return n.yield;
161154
}
162155

163156
/**

lib/src/main/java/com/cloudbees/groovy/cps/impl/ContinuationGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import java.util.function.Function;
24-
import javax.annotation.CheckReturnValue;
24+
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
2525
import org.codehaus.groovy.runtime.InvokerInvocationException;
2626
import org.codehaus.groovy.runtime.ScriptBytecodeAdapter;
2727
import org.codehaus.groovy.runtime.callsite.CallSite;

lib/src/test/java/com/cloudbees/groovy/cps/CpsDefaultGroovyMethodsTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ public static Iterable<Object[]> generateParameters() {
334334
asList("uniqueSet", "([1, 2, -2, 3] as HashSet).unique { i -> i * i }.collect { it.abs() } as HashSet", asList(1, 2, 3) as HashSet),
335335
*/
336336

337-
// TODO: use?
338-
339337
// TODO: with?
340338

341339
// .withDefault

lib/src/test/java/com/cloudbees/groovy/cps/CpsTransformerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ public void rehydrateClosure() throws Throwable {
769769

770770
@Issue("https://github.com/cloudbees/groovy-cps/issues/16")
771771
@Test
772-
@Ignore
772+
@Ignore("cannot easily be supported")
773773
public void category() throws Throwable {
774774
assertEvaluate("FOO",
775775
"class BarCategory {\n" +

lib/src/test/java/com/cloudbees/groovy/cps/impl/NotBlockTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import groovy.lang.Script;
88
import java.io.InputStream;
99
import java.io.ObjectInputStream;
10-
import java.util.Collections;
1110
import org.junit.Test;
1211

1312
import static org.hamcrest.CoreMatchers.equalTo;
@@ -38,6 +37,6 @@ public void serialFormBackwardsCompatibility() throws Throwable {
3837
c = (Continuable)ois.readObject();
3938
}
4039
assertTrue(c.isResumable());
41-
assertThat(c.run0(new Outcome(false, null), Collections.emptyList()).replay(), equalTo(true));
40+
assertThat(c.run0(new Outcome(false, null)).replay(), equalTo(true));
4241
}
4342
}

plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
<dependency>
248248
<groupId>org.testcontainers</groupId>
249249
<artifactId>testcontainers</artifactId>
250-
<version>1.19.6</version>
250+
<version>1.19.7</version>
251251
<scope>test</scope>
252252
<exclusions>
253253
<!-- Provided by Jenkins core -->

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
import java.io.IOException;
8585
import java.util.ArrayList;
8686
import java.util.Collections;
87-
import java.util.HashMap;
8887
import java.util.List;
8988
import java.util.Map;
9089
import java.util.Map.Entry;
@@ -256,7 +255,7 @@ public class CpsFlowExecution extends FlowExecution implements BlockableResume {
256255
* Any additional scripts {@linkplain CpsGroovyShell#parse(GroovyCodeSource) parsed} afterward, keyed by
257256
* their FQCN.
258257
*/
259-
/*package*/ /*final*/ Map<String,String> loadedScripts = new HashMap<>();
258+
/*package*/ /*final*/ Map<String,String> loadedScripts = new LinkedHashMap<>();
260259

261260
private final boolean sandbox;
262261
private transient /*almost final*/ FlowExecutionOwner owner;
@@ -706,12 +705,6 @@ private CpsScript parseScript() throws IOException {
706705
}
707706

708707
s.execution = this;
709-
if (false) {
710-
System.out.println("scriptName="+s.getClass().getName());
711-
System.out.println(List.of(s.getClass().getInterfaces()));
712-
System.out.println(List.of(s.getClass().getDeclaredFields()));
713-
System.out.println(List.of(s.getClass().getDeclaredMethods()));
714-
}
715708
return s;
716709
}
717710

@@ -1939,7 +1932,7 @@ public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingCont
19391932
}
19401933

19411934
if (result.loadedScripts == null) {
1942-
result.loadedScripts = new HashMap<>(); // field added later
1935+
result.loadedScripts = new LinkedHashMap<>(); // field added later
19431936
}
19441937
result.liveTimings = result.timings == null ?
19451938
new ConcurrentHashMap<>() :

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
import java.util.Collection;
4949
import java.util.Collections;
5050
import java.util.List;
51+
import java.util.stream.Collectors;
52+
5153
import jenkins.model.Jenkins;
5254
import jenkins.scm.api.SCMFileSystem;
5355
import jenkins.security.HMACConfidentialKey;
@@ -218,7 +220,8 @@ private String getFilePathSuffix() {
218220
public Collection<? extends SCMDescriptor<?>> getApplicableDescriptors() {
219221
StaplerRequest req = Stapler.getCurrentRequest();
220222
Job<?,?> job = req != null ? req.findAncestorObject(Job.class) : null;
221-
return SCM._for(job);
223+
return SCM._for(job).stream().filter(d -> !"org.jenkinsci.plugins.multiplescms.MultiSCM".equals(d.getId())).collect(Collectors.toList());
224+
222225
}
223226

224227
// TODO doCheckLightweight impossible to write even though we have SCMFileSystem.supports(SCM), because form validation cannot pass the SCM object

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThread.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import com.cloudbees.groovy.cps.Continuable;
2828
import com.cloudbees.groovy.cps.Outcome;
29-
import com.google.common.collect.ImmutableList;
3029
import com.google.common.util.concurrent.FutureCallback;
3130
import java.io.IOException;
3231
import org.jenkinsci.plugins.workflow.cps.persistence.PersistIn;
@@ -43,7 +42,6 @@
4342
import java.util.concurrent.TimeUnit;
4443
import java.util.logging.Logger;
4544

46-
import org.jenkinsci.plugins.workflow.cps.persistence.IteratorHack;
4745

4846
import static java.util.logging.Level.FINE;
4947
import static org.jenkinsci.plugins.workflow.cps.persistence.PersistenceContext.PROGRAM;
@@ -162,11 +160,6 @@ public StepExecution getStep() {
162160
this.step = step;
163161
}
164162

165-
private static final List<Class> CATEGORIES = ImmutableList.<Class>builder()
166-
.addAll(Continuable.categories)
167-
.add(IteratorHack.class)
168-
.build();
169-
170163
/**
171164
* Executes CPS code synchronously a little bit more, until it hits
172165
* the point the workflow needs to be dehydrated.
@@ -184,7 +177,7 @@ public StepExecution getStep() {
184177
LOGGER.fine(() -> "runNextChunk on " + resumeValue);
185178
final Outcome o = resumeValue;
186179
resumeValue = null;
187-
outcome = program.run0(o, CATEGORIES);
180+
outcome = program.run0(o);
188181
if (outcome.getAbnormal() != null) {
189182
LOGGER.log(FINE, "ran and produced error", outcome.getAbnormal());
190183
} else {

0 commit comments

Comments
 (0)