Skip to content

Commit

Permalink
Upgrade to Jakarta EE 9 (#167)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people authored Feb 17, 2025
1 parent 8228f34 commit 81a319a
Show file tree
Hide file tree
Showing 20 changed files with 166 additions and 207 deletions.
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-text-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
Expand Down
49 changes: 22 additions & 27 deletions src/main/java/hudson/plugins/plot/CSVSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.ObjectUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Represents a plot data series configuration from an CSV file.
Expand Down Expand Up @@ -113,7 +113,7 @@ public CSVSeries(String file, String url, String inclusionFlag, String exclusion
}

if (results == 0) {
this.exclusionValuesList = Arrays.asList(PAT_COMMA.split((String) this.exclusionValues));
this.exclusionValuesList = Arrays.asList(PAT_COMMA.split(this.exclusionValues));
}
}
loadExclusionSet();
Expand Down Expand Up @@ -195,7 +195,7 @@ private List<PlotPoint> loadSeriesFile(FilePath seriesFile, int buildNumber) {
}

// load existing plot file
inputReader = new InputStreamReader(in, Charset.defaultCharset().name());
inputReader = new InputStreamReader(in, Charset.defaultCharset());
reader = new CSVReader(inputReader);
String[] nextLine;

Expand All @@ -206,7 +206,7 @@ private List<PlotPoint> loadSeriesFile(FilePath seriesFile, int buildNumber) {
int lineNum = 0;
while ((nextLine = reader.readNext()) != null) {
// skip empty lines
if (nextLine.length == 1 && nextLine[0].length() == 0) {
if (nextLine.length == 1 && nextLine[0].isEmpty()) {

Check warning on line 209 in src/main/java/hudson/plugins/plot/CSVSeries.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 209 is only partially covered, 3 branches are missing
continue;
}

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

// empty value, caused by e.g. trailing comma in CSV
if (yvalue.trim().length() == 0) {
if (yvalue.trim().isEmpty()) {
continue;
}

Expand Down Expand Up @@ -278,27 +278,22 @@ private boolean excludePoint(final String label, int index) {
return false;
}

boolean retVal;
switch (inclusionFlag) {
case INCLUDE_BY_STRING:
// if the set contains it, don't exclude it.
retVal = !checkExclusionSet(label);
break;
case EXCLUDE_BY_STRING:
// if the set doesn't contain it, exclude it.
retVal = checkExclusionSet(label);
break;
case INCLUDE_BY_COLUMN:
// if the set contains it, don't exclude it.
retVal = !(colExclusionSet.contains(Integer.valueOf(index)));
break;
case EXCLUDE_BY_COLUMN:
// if the set doesn't contain it, don't exclude it.
retVal = colExclusionSet.contains(Integer.valueOf(index));
break;
default:
retVal = false;
}
boolean retVal =
switch (inclusionFlag) {
case INCLUDE_BY_STRING ->
// if the set contains it, don't exclude it.
!checkExclusionSet(label);
case EXCLUDE_BY_STRING ->
// if the set doesn't contain it, exclude it.
checkExclusionSet(label);
case INCLUDE_BY_COLUMN ->
// if the set contains it, don't exclude it.
!(colExclusionSet.contains(index));
case EXCLUDE_BY_COLUMN ->
// if the set doesn't contain it, don't exclude it.
colExclusionSet.contains(index);

Check warning on line 294 in src/main/java/hudson/plugins/plot/CSVSeries.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 291-294 are not covered by tests
default -> false;
};

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

@Override
public Series newInstance(StaplerRequest req, @NonNull JSONObject formData) throws FormException {
public Series newInstance(StaplerRequest2 req, @NonNull JSONObject formData) throws FormException {
return SeriesFactory.createSeries(formData, req);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.commons.lang.ObjectUtils;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

/**
* @author lucinka
Expand All @@ -33,12 +33,12 @@ public class MatrixPlotPublisher extends AbstractPlotPublisher {

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

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

/**
* Configured plots.
*/
private List<Plot> plots = new ArrayList<Plot>();
private List<Plot> plots = new ArrayList<>();

public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) {
if (urlGroup == null || "nogroup".equals(urlGroup)) {
Expand All @@ -51,7 +51,7 @@ public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) {
plotList.add(plot);
}
}
if (plotList.size() > 0) {
if (!plotList.isEmpty()) {

Check warning on line 54 in src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 54 is only partially covered, one branch is missing
return plotList.get(0).group;
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public void addPlot(Plot plot) {
*/
public List<Plot> getPlots(MatrixConfiguration configuration) {
List<Plot> p = plotsOfConfigurations.get(configuration);
return (p != null) ? p : new ArrayList<Plot>();
return (p != null) ? p : new ArrayList<>();

Check warning on line 113 in src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 113 is not covered by tests
}

public List<Plot> getPlots() {
Expand Down Expand Up @@ -164,7 +164,7 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
p.yaxisMaximum,
p.description);
plot.series = p.series;
plot.setProject((MatrixConfiguration) build.getProject());
plot.setProject(build.getProject());
addPlot(plot);
}
}
Expand Down Expand Up @@ -226,17 +226,17 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
* Called when the user saves the project configuration.
*/
@Override
public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
public Publisher newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
MatrixPlotPublisher publisher = new MatrixPlotPublisher();
List<Plot> plots = new ArrayList<Plot>();
List<Plot> plots = new ArrayList<>();

Check warning on line 231 in src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 231 is not covered by tests
for (Object data : SeriesFactory.getArray(formData.get("plots"))) {
plots.add(bindPlot((JSONObject) data, req));
}
publisher.setPlots(plots);
return publisher;
}

private static Plot bindPlot(JSONObject data, StaplerRequest req) {
private static Plot bindPlot(JSONObject data, StaplerRequest2 req) {
Plot p = req.bindJSON(Plot.class, data);
p.series = SeriesFactory.createSeriesList(data.get("series"), req);
return p;
Expand Down
Loading

0 comments on commit 81a319a

Please sign in to comment.