Skip to content

Commit 576e920

Browse files
Require Jenkins 2.479.1 and Jakarta EE 9 (#81)
Co-authored-by: strangelookingnerd <[email protected]>
1 parent a08e0bc commit 576e920

25 files changed

+155
-162
lines changed

pom.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.jenkins-ci.plugins</groupId>
55
<artifactId>plugin</artifactId>
6-
<version>4.82</version>
6+
<version>5.7</version>
77
</parent>
88

99
<artifactId>robot</artifactId>
@@ -38,8 +38,8 @@
3838

3939
<properties>
4040
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
41-
<jenkins.baseline>2.414</jenkins.baseline>
42-
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
41+
<jenkins.baseline>2.479</jenkins.baseline>
42+
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
4343
</properties>
4444

4545
<scm>
@@ -53,7 +53,7 @@
5353
<dependency>
5454
<groupId>io.jenkins.tools.bom</groupId>
5555
<artifactId>bom-${jenkins.baseline}.x</artifactId>
56-
<version>2982.vdce2153031a_0</version>
56+
<version>4051.v78dce3ce8b_d6</version>
5757
<scope>import</scope>
5858
<type>pom</type>
5959
</dependency>
@@ -69,10 +69,6 @@
6969
<artifactId>mockito-core</artifactId>
7070
<scope>test</scope>
7171
</dependency>
72-
<dependency>
73-
<groupId>org.jenkins-ci.plugins</groupId>
74-
<artifactId>junit</artifactId>
75-
</dependency>
7672
<dependency>
7773
<groupId>org.jenkins-ci.plugins.workflow</groupId>
7874
<artifactId>workflow-step-api</artifactId>

src/main/java/hudson/plugins/robot/AggregatedRobotAction.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
import hudson.util.ChartUtil;
2525
import hudson.util.Graph;
2626
import org.apache.commons.lang.StringUtils;
27-
import org.kohsuke.stapler.StaplerRequest;
28-
import org.kohsuke.stapler.StaplerResponse;
27+
import org.kohsuke.stapler.StaplerRequest2;
28+
import org.kohsuke.stapler.StaplerResponse2;
2929

3030
import java.io.IOException;
31+
import java.io.Serial;
3132
import java.util.Calendar;
3233

3334
public class AggregatedRobotAction implements Action {
@@ -82,7 +83,7 @@ public String getUrlName() {
8283
* @param rsp The used StaplerResponse
8384
* @throws IOException thrown exception
8485
*/
85-
public void doGraph(StaplerRequest req, StaplerResponse rsp)
86+
public void doGraph(StaplerRequest2 req, StaplerResponse2 rsp)
8687
throws IOException {
8788
if (ChartUtil.awtProblemCause != null) {
8889
rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
@@ -96,17 +97,18 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp)
9697
String label = getChildBuildAction(build).getxAxisLabel();
9798
String labelFormat = StringUtils.isBlank(label) ? RobotConfig.getInstance().getXAxisLabelFormat() : label;
9899
Graph g = RobotGraphHelper.createTestResultsGraphForTestObject(getResult(),
99-
Boolean.valueOf(req.getParameter("zoomSignificant")),
100-
false, Boolean.valueOf(req.getParameter("hd")),
101-
Boolean.valueOf(req.getParameter("failedOnly")),
102-
Boolean.valueOf(req.getParameter("criticalOnly")),
100+
Boolean.parseBoolean(req.getParameter("zoomSignificant")),
101+
false, Boolean.parseBoolean(req.getParameter("hd")),
102+
Boolean.parseBoolean(req.getParameter("failedOnly")),
103+
Boolean.parseBoolean(req.getParameter("criticalOnly")),
103104
labelFormat,
104105
Integer.parseInt(req.getParameter("maxBuildsToShow")));
105106
g.doPng(req, rsp);
106107
}
107108

108109
public static class AggregatedRobotResult extends RobotResult {
109110

111+
@Serial
110112
private static final long serialVersionUID = 1L;
111113
private final transient AggregatedRobotAction parent;
112114
private int passed, failed, skipped;

src/main/java/hudson/plugins/robot/RobotBuildAction.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@
3838
import java.util.logging.Level;
3939
import java.util.logging.Logger;
4040

41-
import javax.servlet.ServletException;
41+
import jakarta.servlet.ServletException;
4242

4343
import org.apache.commons.lang.StringUtils;
4444
import org.kohsuke.stapler.StaplerProxy;
45-
import org.kohsuke.stapler.StaplerRequest;
46-
import org.kohsuke.stapler.StaplerResponse;
47-
45+
import org.kohsuke.stapler.StaplerRequest2;
46+
import org.kohsuke.stapler.StaplerResponse2;
4847
import com.thoughtworks.xstream.XStream;
4948

5049
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -136,7 +135,7 @@ synchronized public void setResult(RobotResult result, TaskListener listener) {
136135

137136
cacheRobotResult(result);
138137
}
139-
138+
140139
/**
141140
* Returns Robotresult. If not in memory loads it from disk.
142141
*/
@@ -237,7 +236,7 @@ public String getxAxisLabel() {
237236
* @throws ServletException thrown exception
238237
* @throws InterruptedException thrown exception
239238
*/
240-
public void doIndex(StaplerRequest req, StaplerResponse rsp)
239+
public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp)
241240
throws IOException, ServletException, InterruptedException {
242241
String indexFile = getReportFileName();
243242
FilePath robotDir = getRobotDir();
@@ -261,7 +260,7 @@ public void doIndex(StaplerRequest req, StaplerResponse rsp)
261260
* @param rsp StaplerResponse
262261
* @throws IOException thrown exception
263262
*/
264-
public void doGraph(StaplerRequest req, StaplerResponse rsp)
263+
public void doGraph(StaplerRequest2 req, StaplerResponse2 rsp)
265264
throws IOException {
266265
// TODO: When is this executed?
267266
if (ChartUtil.awtProblemCause != null) {
@@ -280,10 +279,10 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp)
280279

281280
String labelFormat = StringUtils.isBlank(xAxisLabel) ? RobotConfig.getInstance().getXAxisLabelFormat() : xAxisLabel;
282281
Graph g = RobotGraphHelper.createTestResultsGraphForTestObject(getResult(),
283-
Boolean.valueOf(req.getParameter("zoomSignificant")), false,
284-
Boolean.valueOf(req.getParameter("hd")),
285-
Boolean.valueOf(req.getParameter("failedOnly")),
286-
Boolean.valueOf(req.getParameter("criticalOnly")),
282+
Boolean.parseBoolean(req.getParameter("zoomSignificant")), false,
283+
Boolean.parseBoolean(req.getParameter("hd")),
284+
Boolean.parseBoolean(req.getParameter("failedOnly")),
285+
Boolean.parseBoolean(req.getParameter("criticalOnly")),
287286
labelFormat,
288287
Integer.parseInt(maxBuildsReq));
289288
g.doPng(req, rsp);

src/main/java/hudson/plugins/robot/RobotConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import hudson.Extension;
44
import jenkins.model.GlobalConfiguration;
55
import net.sf.json.JSONObject;
6-
import org.kohsuke.stapler.StaplerRequest;
6+
import org.kohsuke.stapler.StaplerRequest2;
77

88
@Extension
99
public class RobotConfig extends GlobalConfiguration {
@@ -21,7 +21,7 @@ public static RobotConfig getInstance() {
2121
}
2222

2323
@Override
24-
public boolean configure(StaplerRequest req, JSONObject o) throws FormException {
24+
public boolean configure(StaplerRequest2 req, JSONObject o) throws FormException {
2525
// Get Robot Framework section
2626
o = o.getJSONObject("robotFramework");
2727

src/main/java/hudson/plugins/robot/RobotParser.java

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.File;
2929
import java.io.FileInputStream;
3030
import java.io.IOException;
31+
import java.io.Serial;
3132
import java.util.ArrayList;
3233
import java.util.Arrays;
3334
import java.util.List;
@@ -52,6 +53,7 @@ public RobotResult parse(String outputFileLocations, String outputPath, Run<?, ?
5253
public static final class RobotParserCallable implements
5354
FilePath.FileCallable<RobotResult> {
5455

56+
@Serial
5557
private static final long serialVersionUID = 1L;
5658
private final String outputFileLocations;
5759
private final String logFileName;
@@ -95,19 +97,16 @@ public RobotResult invoke(File ws, VirtualChannel channel)
9597
String dirFromFileGLOB = new File(file).getParent();
9698
if(dirFromFileGLOB != null)
9799
baseDirectory = new File(baseDirectory, dirFromFileGLOB);
98-
FileInputStream inputStream = new FileInputStream(reportFile);
99-
try {
100-
XMLStreamReader reader = factory.createXMLStreamReader(inputStream, "UTF-8");
101-
try {
102-
parseResult(result, reader, baseDirectory);
103-
} finally {
104-
reader.close();
105-
}
106-
} catch (XMLStreamException e1) {
107-
throw new IOException("Parsing of output xml failed!", e1);
108-
} finally {
109-
inputStream.close();
110-
}
100+
try (FileInputStream inputStream = new FileInputStream(reportFile)) {
101+
XMLStreamReader reader = factory.createXMLStreamReader(inputStream, "UTF-8");
102+
try {
103+
parseResult(result, reader, baseDirectory);
104+
} finally {
105+
reader.close();
106+
}
107+
} catch (XMLStreamException e1) {
108+
throw new IOException("Parsing of output xml failed!", e1);
109+
}
111110
}
112111
return result;
113112
}
@@ -196,23 +195,20 @@ private XMLStreamException xmlException(String message, XMLStreamReader reader)
196195
private RobotSuiteResult getSplitXMLSuite(RobotTestObject parent, File baseDirectory, String path) throws XMLStreamException, IOException {
197196
XMLInputFactory factory = XMLInputFactory.newInstance();
198197
factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
199-
FileInputStream inputStream = new FileInputStream(new File(baseDirectory, path));
200-
try {
201-
XMLStreamReader splitReader = factory.createXMLStreamReader(inputStream, "UTF-8");
202-
try {
203-
while(splitReader.hasNext()){
204-
splitReader.next();
205-
if(splitReader.isStartElement() && "suite".equals(splitReader.getLocalName())) {
206-
return processSuite(splitReader, parent, baseDirectory);
207-
}
208-
}
209-
throw xmlException("Illegal split xml output. Could not find suite element.", splitReader);
210-
} finally {
211-
splitReader.close();
212-
}
213-
} finally {
214-
inputStream.close();
215-
}
198+
try (FileInputStream inputStream = new FileInputStream(new File(baseDirectory, path))) {
199+
XMLStreamReader splitReader = factory.createXMLStreamReader(inputStream, "UTF-8");
200+
try {
201+
while (splitReader.hasNext()) {
202+
splitReader.next();
203+
if (splitReader.isStartElement() && "suite".equals(splitReader.getLocalName())) {
204+
return processSuite(splitReader, parent, baseDirectory);
205+
}
206+
}
207+
throw xmlException("Illegal split xml output. Could not find suite element.", splitReader);
208+
} finally {
209+
splitReader.close();
210+
}
211+
}
216212
}
217213

218214
private String ignoreUntilStarts(XMLStreamReader reader, String... elements) throws XMLStreamException {
@@ -281,9 +277,7 @@ private String getSpacesPerNestedLevel(int level) {
281277
if (level > 0) {
282278
spaces.append("\n");
283279
}
284-
for (int i = 0; i < level; i++) {
285-
spaces.append(" ");
286-
}
280+
spaces.append(" ".repeat(Math.max(0, level)));
287281
return spaces.toString();
288282
}
289283

src/main/java/hudson/plugins/robot/RobotProjectAction.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import java.io.IOException;
2424
import java.util.Calendar;
2525

26-
import javax.servlet.ServletException;
26+
import jakarta.servlet.ServletException;
2727

28-
import org.kohsuke.stapler.StaplerRequest;
29-
import org.kohsuke.stapler.StaplerResponse;
28+
import org.kohsuke.stapler.StaplerRequest2;
29+
import org.kohsuke.stapler.StaplerResponse2;
3030

3131
public class RobotProjectAction implements Action {
3232

@@ -53,11 +53,8 @@ public RobotProjectAction(Job<?, ?> project) {
5353
* @return true if there are any builds in the associated project.
5454
*/
5555
public boolean isDisplayGraph() {
56-
if (getLastBuildAction() != null)
57-
return true;
58-
59-
return false;
60-
}
56+
return getLastBuildAction() != null;
57+
}
6158

6259
/**
6360
* Return the action of last build associated with robot
@@ -66,7 +63,7 @@ public boolean isDisplayGraph() {
6663
public Action getLastBuildAction(){
6764
Run<?, ?> lastBuild = getLastBuildWithRobot();
6865
if(lastBuild != null){
69-
RobotBuildAction action = (RobotBuildAction)lastBuild.getAction(RobotBuildAction.class);
66+
RobotBuildAction action = lastBuild.getAction(RobotBuildAction.class);
7067
if (action == null)
7168
return lastBuild.getAction(AggregatedRobotAction.class);
7269
return action;
@@ -81,7 +78,7 @@ public Action getLastBuildAction(){
8178
* @throws IOException thrown exception
8279
* @throws ServletException thrown exception
8380
*/
84-
public void doGraph(StaplerRequest req, StaplerResponse rsp)
81+
public void doGraph(StaplerRequest2 req, StaplerResponse2 rsp)
8582
throws IOException, ServletException {
8683
if (ChartUtil.awtProblemCause != null) {
8784
rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
@@ -109,7 +106,7 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp)
109106
* @param rsp StaplerResponse
110107
* @throws IOException thrown exception
111108
*/
112-
public void doIndex(StaplerRequest req, StaplerResponse rsp)
109+
public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp)
113110
throws IOException {
114111
Run<?,?> lastBuild = getLastBuildWithRobot();
115112
if (lastBuild == null) {
@@ -122,9 +119,9 @@ public void doIndex(StaplerRequest req, StaplerResponse rsp)
122119

123120

124121
private Run<?, ?> getLastBuildWithRobot() {
125-
Run<?, ?> lastBuild = (Run<?, ?>) project.getLastBuild();
122+
Run<?, ?> lastBuild = project.getLastBuild();
126123
while (lastBuild != null
127-
&& (lastBuild.getAction(RobotBuildAction.class) == null
124+
&& (lastBuild.getAction(RobotBuildAction.class) == null
128125
&& lastBuild.getAction(AggregatedRobotAction.class) == null)) {
129126
lastBuild = lastBuild.getPreviousBuild();
130127
}

src/main/java/hudson/plugins/robot/RobotPublisher.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@
3232

3333
import java.io.IOException;
3434
import java.io.PrintStream;
35+
import java.io.Serial;
3536
import java.io.Serializable;
3637
import java.util.ArrayList;
3738
import java.util.Collection;
3839

39-
import javax.servlet.ServletException;
40+
import jakarta.servlet.ServletException;
4041

4142
import jenkins.tasks.SimpleBuildStep;
4243
import org.apache.commons.lang.StringUtils;
@@ -49,6 +50,7 @@
4950
public class RobotPublisher extends Recorder implements Serializable,
5051
MatrixAggregatable, SimpleBuildStep {
5152

53+
@Serial
5254
private static final long serialVersionUID = 1L;
5355

5456
protected static final String DEFAULT_REPORT_FILE = "report.html";
@@ -441,7 +443,6 @@ public static final class DescriptorImpl extends
441443
/**
442444
* {@inheritDoc}
443445
*/
444-
@SuppressWarnings("rawtypes")
445446
@Override
446447
public boolean isApplicable(Class<? extends AbstractProject> aClass) {
447448
return true;
@@ -493,10 +494,7 @@ public FormValidation doCheckPassThreshold(@QueryParameter String value)
493494
private boolean isPercentageValue(String value) {
494495
try {
495496
double doubleValue = Double.parseDouble(value);
496-
if (doubleValue <= 100 && doubleValue >= 0)
497-
return true;
498-
else
499-
return false;
497+
return doubleValue <= 100 && doubleValue >= 0;
500498
} catch (NumberFormatException e) {
501499
return false;
502500
}

src/main/java/hudson/plugins/robot/RobotStepExecution.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hudson.plugins.robot;
22

3+
import java.io.Serial;
34
import java.util.logging.Logger;
45

56
import hudson.EnvVars;
@@ -15,10 +16,11 @@ public class RobotStepExecution extends SynchronousNonBlockingStepExecution<Void
1516

1617
private static final Logger logger = Logger.getLogger(RobotStepExecution.class.getName());
1718

18-
private static final long serialVersionUID = 1L;
19+
@Serial
20+
private static final long serialVersionUID = 1L;
1921

2022
private transient final RobotStep step;
21-
23+
2224
RobotStepExecution(RobotStep step, StepContext context) {
2325
super(context);
2426
this.step = step;

src/main/java/hudson/plugins/robot/graph/RobotBuildLabel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public int compareTo(RobotBuildLabel that) {
3030

3131
@Override
3232
public boolean equals(Object o) {
33-
if(!(o instanceof RobotBuildLabel)) return false;
34-
RobotBuildLabel that = (RobotBuildLabel) o;
33+
if(!(o instanceof RobotBuildLabel that)) return false;
3534
return run==that.run;
3635
}
3736

0 commit comments

Comments
 (0)