Skip to content

Commit 81a319a

Browse files
strangelookingnerdMarkEWaitegounthar
authored
Upgrade to Jakarta EE 9 (jenkinsci#167)
* Require Jenkins 2.479.1 and Jakarta EE 9 * Remove empty test Test with no statements is not useful * Retain transient modifier to not alter serialization * Retain transient modifier to not alter serialization --------- Co-authored-by: strangelookingnerd <strangelookingnerd@users.noreply.github.com> Co-authored-by: Mark Waite <mark.earl.waite@gmail.com> Co-authored-by: Bruno Verachten <gounthar@gmail.com>
1 parent 8228f34 commit 81a319a

20 files changed

Lines changed: 166 additions & 207 deletions

pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@
8181
<groupId>io.jenkins.plugins</groupId>
8282
<artifactId>commons-text-api</artifactId>
8383
</dependency>
84-
<dependency>
85-
<groupId>org.jenkins-ci.plugins</groupId>
86-
<artifactId>junit</artifactId>
87-
</dependency>
8884
<dependency>
8985
<groupId>org.jenkins-ci.plugins</groupId>
9086
<artifactId>matrix-project</artifactId>

src/main/java/hudson/plugins/plot/CSVSeries.java

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.apache.commons.lang.ArrayUtils;
3131
import org.apache.commons.lang.ObjectUtils;
3232
import org.kohsuke.stapler.DataBoundConstructor;
33-
import org.kohsuke.stapler.StaplerRequest;
33+
import org.kohsuke.stapler.StaplerRequest2;
3434

3535
/**
3636
* Represents a plot data series configuration from an CSV file.
@@ -113,7 +113,7 @@ public CSVSeries(String file, String url, String inclusionFlag, String exclusion
113113
}
114114

115115
if (results == 0) {
116-
this.exclusionValuesList = Arrays.asList(PAT_COMMA.split((String) this.exclusionValues));
116+
this.exclusionValuesList = Arrays.asList(PAT_COMMA.split(this.exclusionValues));
117117
}
118118
}
119119
loadExclusionSet();
@@ -195,7 +195,7 @@ private List<PlotPoint> loadSeriesFile(FilePath seriesFile, int buildNumber) {
195195
}
196196

197197
// load existing plot file
198-
inputReader = new InputStreamReader(in, Charset.defaultCharset().name());
198+
inputReader = new InputStreamReader(in, Charset.defaultCharset());
199199
reader = new CSVReader(inputReader);
200200
String[] nextLine;
201201

@@ -206,7 +206,7 @@ private List<PlotPoint> loadSeriesFile(FilePath seriesFile, int buildNumber) {
206206
int lineNum = 0;
207207
while ((nextLine = reader.readNext()) != null) {
208208
// skip empty lines
209-
if (nextLine.length == 1 && nextLine[0].length() == 0) {
209+
if (nextLine.length == 1 && nextLine[0].isEmpty()) {
210210
continue;
211211
}
212212

@@ -217,7 +217,7 @@ private List<PlotPoint> loadSeriesFile(FilePath seriesFile, int buildNumber) {
217217
yvalue = nextLine[index].trim();
218218

219219
// empty value, caused by e.g. trailing comma in CSV
220-
if (yvalue.trim().length() == 0) {
220+
if (yvalue.trim().isEmpty()) {
221221
continue;
222222
}
223223

@@ -278,27 +278,22 @@ private boolean excludePoint(final String label, int index) {
278278
return false;
279279
}
280280

281-
boolean retVal;
282-
switch (inclusionFlag) {
283-
case INCLUDE_BY_STRING:
284-
// if the set contains it, don't exclude it.
285-
retVal = !checkExclusionSet(label);
286-
break;
287-
case EXCLUDE_BY_STRING:
288-
// if the set doesn't contain it, exclude it.
289-
retVal = checkExclusionSet(label);
290-
break;
291-
case INCLUDE_BY_COLUMN:
292-
// if the set contains it, don't exclude it.
293-
retVal = !(colExclusionSet.contains(Integer.valueOf(index)));
294-
break;
295-
case EXCLUDE_BY_COLUMN:
296-
// if the set doesn't contain it, don't exclude it.
297-
retVal = colExclusionSet.contains(Integer.valueOf(index));
298-
break;
299-
default:
300-
retVal = false;
301-
}
281+
boolean retVal =
282+
switch (inclusionFlag) {
283+
case INCLUDE_BY_STRING ->
284+
// if the set contains it, don't exclude it.
285+
!checkExclusionSet(label);
286+
case EXCLUDE_BY_STRING ->
287+
// if the set doesn't contain it, exclude it.
288+
checkExclusionSet(label);
289+
case INCLUDE_BY_COLUMN ->
290+
// if the set contains it, don't exclude it.
291+
!(colExclusionSet.contains(index));
292+
case EXCLUDE_BY_COLUMN ->
293+
// if the set doesn't contain it, don't exclude it.
294+
colExclusionSet.contains(index);
295+
default -> false;
296+
};
302297

303298
if (LOGGER.isLoggable(Level.FINEST)) {
304299
LOGGER.finest(((retVal) ? "excluded" : "included") + " CSV Column: " + index + " : " + label);
@@ -405,7 +400,7 @@ public String getDisplayName() {
405400
}
406401

407402
@Override
408-
public Series newInstance(StaplerRequest req, @NonNull JSONObject formData) throws FormException {
403+
public Series newInstance(StaplerRequest2 req, @NonNull JSONObject formData) throws FormException {
409404
return SeriesFactory.createSeries(formData, req);
410405
}
411406
}

src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.commons.lang.ObjectUtils;
2525
import org.kohsuke.stapler.AncestorInPath;
2626
import org.kohsuke.stapler.QueryParameter;
27-
import org.kohsuke.stapler.StaplerRequest;
27+
import org.kohsuke.stapler.StaplerRequest2;
2828

2929
/**
3030
* @author lucinka
@@ -33,12 +33,12 @@ public class MatrixPlotPublisher extends AbstractPlotPublisher {
3333

3434
private transient Map<MatrixConfiguration, List<Plot>> plotsOfConfigurations = new HashMap<>();
3535

36-
private transient Map<String, List<Plot>> groupMap = new HashMap<String, List<Plot>>();
36+
private transient Map<String, List<Plot>> groupMap = new HashMap<>();
3737

3838
/**
3939
* Configured plots.
4040
*/
41-
private List<Plot> plots = new ArrayList<Plot>();
41+
private List<Plot> plots = new ArrayList<>();
4242

4343
public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) {
4444
if (urlGroup == null || "nogroup".equals(urlGroup)) {
@@ -51,7 +51,7 @@ public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) {
5151
plotList.add(plot);
5252
}
5353
}
54-
if (plotList.size() > 0) {
54+
if (!plotList.isEmpty()) {
5555
return plotList.get(0).group;
5656
}
5757
}
@@ -110,7 +110,7 @@ public void addPlot(Plot plot) {
110110
*/
111111
public List<Plot> getPlots(MatrixConfiguration configuration) {
112112
List<Plot> p = plotsOfConfigurations.get(configuration);
113-
return (p != null) ? p : new ArrayList<Plot>();
113+
return (p != null) ? p : new ArrayList<>();
114114
}
115115

116116
public List<Plot> getPlots() {
@@ -164,7 +164,7 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
164164
p.yaxisMaximum,
165165
p.description);
166166
plot.series = p.series;
167-
plot.setProject((MatrixConfiguration) build.getProject());
167+
plot.setProject(build.getProject());
168168
addPlot(plot);
169169
}
170170
}
@@ -226,17 +226,17 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
226226
* Called when the user saves the project configuration.
227227
*/
228228
@Override
229-
public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
229+
public Publisher newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
230230
MatrixPlotPublisher publisher = new MatrixPlotPublisher();
231-
List<Plot> plots = new ArrayList<Plot>();
231+
List<Plot> plots = new ArrayList<>();
232232
for (Object data : SeriesFactory.getArray(formData.get("plots"))) {
233233
plots.add(bindPlot((JSONObject) data, req));
234234
}
235235
publisher.setPlots(plots);
236236
return publisher;
237237
}
238238

239-
private static Plot bindPlot(JSONObject data, StaplerRequest req) {
239+
private static Plot bindPlot(JSONObject data, StaplerRequest2 req) {
240240
Plot p = req.bindJSON(Plot.class, data);
241241
p.series = SeriesFactory.createSeriesList(data.get("series"), req);
242242
return p;

0 commit comments

Comments
 (0)