From f801106c06297e55ab15094d1c6fbd2b94046be0 Mon Sep 17 00:00:00 2001 From: strangelookingnerd Date: Fri, 7 Feb 2025 17:19:41 +0100 Subject: [PATCH 1/4] Require Jenkins 2.479.1 and Jakarta EE 9 --- pom.xml | 20 +--- .../java/hudson/plugins/plot/CSVSeries.java | 57 +++++----- .../plugins/plot/MatrixPlotPublisher.java | 18 +-- src/main/java/hudson/plugins/plot/Plot.java | 105 ++++++++---------- .../java/hudson/plugins/plot/PlotAction.java | 6 +- .../java/hudson/plugins/plot/PlotBuilder.java | 10 +- .../plugins/plot/PlotCategoryDataset.java | 6 +- .../hudson/plugins/plot/PlotDescriptor.java | 6 +- .../hudson/plugins/plot/PlotPublisher.java | 4 +- .../java/hudson/plugins/plot/PlotReport.java | 11 +- .../hudson/plugins/plot/PropertiesSeries.java | 8 +- src/main/java/hudson/plugins/plot/Series.java | 8 +- .../hudson/plugins/plot/SeriesFactory.java | 6 +- .../java/hudson/plugins/plot/XMLSeries.java | 34 +++--- .../hudson/plugins/plot/CSVReaderTest.java | 2 +- .../hudson/plugins/plot/CSVSeriesTest.java | 12 +- .../plugins/plot/PlotBuildActionTest.java | 44 +++----- .../hudson/plugins/plot/SeriesTestCase.java | 2 +- .../hudson/plugins/plot/XMLSeriesTest.java | 26 ++--- 19 files changed, 176 insertions(+), 209 deletions(-) diff --git a/pom.xml b/pom.xml index cea787eb..91ada1ee 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.plugins plugin - 4.88 + 5.7 @@ -27,8 +27,8 @@ -SNAPSHOT jenkinsci/plot-plugin - 2.452 - ${jenkins.baseline}.4 + 2.479 + ${jenkins.baseline}.1 false @@ -38,15 +38,7 @@ io.jenkins.tools.bom bom-${jenkins.baseline}.x - 3944.v1a_e4f8b_452db_ - pom - import - - - - org.jenkins-ci.main - jenkins-bom - ${jenkins.version} + 4051.v78dce3ce8b_d6 pom import @@ -81,10 +73,6 @@ io.jenkins.plugins commons-text-api - - org.jenkins-ci.plugins - junit - org.jenkins-ci.plugins matrix-project diff --git a/src/main/java/hudson/plugins/plot/CSVSeries.java b/src/main/java/hudson/plugins/plot/CSVSeries.java index e50c3ce1..2b0bafb1 100644 --- a/src/main/java/hudson/plugins/plot/CSVSeries.java +++ b/src/main/java/hudson/plugins/plot/CSVSeries.java @@ -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. @@ -38,11 +38,11 @@ * @author Allen Reese */ public class CSVSeries extends Series { - private static final transient Logger LOGGER = Logger.getLogger(CSVSeries.class.getName()); + private static final Logger LOGGER = Logger.getLogger(CSVSeries.class.getName()); // Debugging hack, so I don't have to change FINE/INFO... - private static final transient Level DEFAULT_LOG_LEVEL = Level.FINEST; - private static final transient Pattern PAT_SEMICOLON_ENCLOSURE = Pattern.compile("\"(.*?)\""); - private static final transient Pattern PAT_COMMA = Pattern.compile(","); + private static final Level DEFAULT_LOG_LEVEL = Level.FINEST; + private static final Pattern PAT_SEMICOLON_ENCLOSURE = Pattern.compile("\"(.*?)\""); + private static final Pattern PAT_COMMA = Pattern.compile(","); public enum InclusionFlag { OFF, @@ -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(); @@ -195,7 +195,7 @@ private List 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; @@ -206,7 +206,7 @@ private List 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()) { continue; } @@ -217,7 +217,7 @@ private List 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; } @@ -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); + default -> false; + }; if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest(((retVal) ? "excluded" : "included") + " CSV Column: " + index + " : " + label); @@ -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); } } diff --git a/src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java b/src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java index 7c199446..4f1df14c 100644 --- a/src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java +++ b/src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java @@ -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 @@ -33,12 +33,12 @@ public class MatrixPlotPublisher extends AbstractPlotPublisher { private transient Map> plotsOfConfigurations = new HashMap<>(); - private transient Map> groupMap = new HashMap>(); + private transient Map> groupMap = new HashMap<>(); /** * Configured plots. */ - private List plots = new ArrayList(); + private List plots = new ArrayList<>(); public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) { if (urlGroup == null || "nogroup".equals(urlGroup)) { @@ -51,7 +51,7 @@ public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) { plotList.add(plot); } } - if (plotList.size() > 0) { + if (!plotList.isEmpty()) { return plotList.get(0).group; } } @@ -110,7 +110,7 @@ public void addPlot(Plot plot) { */ public List getPlots(MatrixConfiguration configuration) { List p = plotsOfConfigurations.get(configuration); - return (p != null) ? p : new ArrayList(); + return (p != null) ? p : new ArrayList<>(); } public List getPlots() { @@ -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); } } @@ -226,9 +226,9 @@ public boolean isApplicable(Class 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 plots = new ArrayList(); + List plots = new ArrayList<>(); for (Object data : SeriesFactory.getArray(formData.get("plots"))) { plots.add(bindPlot((JSONObject) data, req)); } @@ -236,7 +236,7 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData) throws For 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; diff --git a/src/main/java/hudson/plugins/plot/Plot.java b/src/main/java/hudson/plugins/plot/Plot.java index fd2c5a08..2b8278f4 100644 --- a/src/main/java/hudson/plugins/plot/Plot.java +++ b/src/main/java/hudson/plugins/plot/Plot.java @@ -54,7 +54,9 @@ import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerResponse2; /** * Represents the configuration for a single plot. A plot can have one or more @@ -476,7 +478,7 @@ public String getCsvFileName() { * Sets the title for the plot from the "title" parameter in the given * StaplerRequest. */ - private void setTitle(StaplerRequest req) { + private void setTitle(StaplerRequest2 req) { urlTitle = req.getParameter("title"); } @@ -488,7 +490,7 @@ public String getTitle() { return title; } - private void setStyle(StaplerRequest req) { + private void setStyle(StaplerRequest2 req) { urlStyle = req.getParameter("style"); } @@ -496,7 +498,7 @@ private String getUrlStyle() { return urlStyle != null ? urlStyle : (style != null ? style : ""); } - private void setUseDescr(StaplerRequest req) { + private void setUseDescr(StaplerRequest2 req) { String u = req.getParameter("usedescr"); if (u == null) { urlUseDescr = null; @@ -513,7 +515,7 @@ private boolean getUrlUseDescr() { * Sets the "hasLegend" parameter in the given StaplerRequest. If the * parameter doesn't exist then a default is used. */ - private void setHasLegend(StaplerRequest req) { + private void setHasLegend(StaplerRequest2 req) { String legend = req.getParameter("haslegend"); hasLegend = legend == null || "on".equalsIgnoreCase(legend) || "true".equalsIgnoreCase(legend); } @@ -527,7 +529,7 @@ public boolean hasLegend() { * given StaplerRequest. If the parameter doesn't exist or isn't an integer * then a default is used. */ - private void setNumBuilds(StaplerRequest req) { + private void setNumBuilds(StaplerRequest2 req) { urlNumBuilds = req.getParameter("numbuilds"); if (urlNumBuilds != null) { try { @@ -553,7 +555,7 @@ public String getNumBuilds() { * given StaplerRequest. If the parameter doesn't exist or isn't an string * then a default is used. */ - private void setDescription(StaplerRequest req) { + private void setDescription(StaplerRequest2 req) { description = req.getParameter("description"); } @@ -566,7 +568,7 @@ public String getDescription() { * "rightbuildnum" parameter in the given StaplerRequest. If the parameter * doesn't exist or isn't an integer then a default is used. */ - private void setRightBuildNum(StaplerRequest req) { + private void setRightBuildNum(StaplerRequest2 req) { String build = req.getParameter("rightbuildnum"); if (StringUtils.isBlank(build)) { rightBuildNum = Integer.MAX_VALUE; @@ -589,7 +591,7 @@ private int getRightBuildNum() { * StaplerRequest. If the parameter doesn't exist or isn't an integer then a * default is used. */ - private void setWidth(StaplerRequest req) { + private void setWidth(StaplerRequest2 req) { String w = req.getParameter("width"); if (w == null) { width = DEFAULT_WIDTH; @@ -612,7 +614,7 @@ private int getWidth() { * StaplerRequest. If the parameter doesn't exist or isn't an integer then a * default is used. */ - private void setHeight(StaplerRequest req) { + private void setHeight(StaplerRequest2 req) { String h = req.getParameter("height"); if (h == null) { height = DEFAULT_HEIGHT; @@ -659,7 +661,7 @@ public void setProject(AbstractProject project) { * @param rsp the response stream * @throws IOException */ - public void plotGraph(StaplerRequest req, StaplerResponse rsp) throws IOException { + public void plotGraph(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException { if (ChartUtil.awtProblemCause != null) { // Not available. Send out error message. rsp.sendRedirect2(req.getContextPath() + "/images/headless.png"); @@ -676,7 +678,12 @@ public void plotGraph(StaplerRequest req, StaplerResponse rsp) throws IOExceptio // need to force regenerate the plot in case build // descriptions (used for tool tips) have changed generatePlot(true); - ChartUtil.generateGraph(req, rsp, plot, getWidth(), getHeight()); + ChartUtil.generateGraph( + StaplerRequest.fromStaplerRequest2(req), + StaplerResponse.fromStaplerResponse2(rsp), + plot, + getWidth(), + getHeight()); } /** @@ -687,7 +694,7 @@ public void plotGraph(StaplerRequest req, StaplerResponse rsp) throws IOExceptio * @param rsp the response stream * @throws IOException */ - public void plotGraphMap(StaplerRequest req, StaplerResponse rsp) throws IOException { + public void plotGraphMap(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException { if (ChartUtil.awtProblemCause != null) { // not available. send out error message rsp.sendRedirect2(req.getContextPath() + "/images/headless.png"); @@ -854,10 +861,10 @@ private void generatePlot(boolean forceGenerate) { ValueAxis rangeAxis = categoryPlot.getRangeAxis(); if ((rangeAxis != null) && (rangeAxis instanceof NumberAxis)) { if (hasYaxisMinimum()) { - ((NumberAxis) rangeAxis).setLowerBound(getYaxisMinimum()); + rangeAxis.setLowerBound(getYaxisMinimum()); } if (hasYaxisMaximum()) { - ((NumberAxis) rangeAxis).setUpperBound(getYaxisMaximum()); + rangeAxis.setUpperBound(getYaxisMaximum()); } ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(!getExclZero()); } @@ -871,14 +878,9 @@ private void generatePlot(boolean forceGenerate) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator(Messages.Plot_Build() + " {1}: {2}", NumberFormat.getInstance())); renderer.setBaseItemURLGenerator(new PointURLGenerator()); - if (renderer instanceof LineAndShapeRenderer) { + if (renderer instanceof LineAndShapeRenderer lasRenderer) { String s = getUrlStyle(); - LineAndShapeRenderer lasRenderer = (LineAndShapeRenderer) renderer; - if ("lineSimple".equalsIgnoreCase(s)) { - lasRenderer.setShapesVisible(false); - } else { - lasRenderer.setShapesVisible(true); - } + lasRenderer.setShapesVisible(!"lineSimple".equalsIgnoreCase(s)); } } @@ -887,39 +889,28 @@ private void generatePlot(boolean forceGenerate) { * dataset. Defaults to using createLineChart. */ private JFreeChart createChart(PlotCategoryDataset dataset) { - switch (ChartStyle.forName(getUrlStyle())) { - case AREA: - return ChartFactory.createAreaChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case BAR: - return ChartFactory.createBarChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case BAR_3D: - return ChartFactory.createBarChart3D( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case LINE_3D: - return ChartFactory.createLineChart3D( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case LINE_SIMPLE: - return ChartFactory.createLineChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case STACKED_AREA: - return ChartFactory.createStackedAreaChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case STACKED_BAR: - return ChartFactory.createStackedBarChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case STACKED_BAR_3D: - return ChartFactory.createStackedBarChart3D( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case WATERFALL: - return ChartFactory.createWaterfallChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - case LINE: - default: - return ChartFactory.createLineChart( - getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); - } + return switch (ChartStyle.forName(getUrlStyle())) { + case AREA -> ChartFactory.createAreaChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case BAR -> ChartFactory.createBarChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case BAR_3D -> ChartFactory.createBarChart3D( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case LINE_3D -> ChartFactory.createLineChart3D( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case LINE_SIMPLE -> ChartFactory.createLineChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case STACKED_AREA -> ChartFactory.createStackedAreaChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case STACKED_BAR -> ChartFactory.createStackedBarChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case STACKED_BAR_3D -> ChartFactory.createStackedBarChart3D( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + case WATERFALL -> ChartFactory.createWaterfallChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + default -> ChartFactory.createLineChart( + getURLTitle(), null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), true, false); + }; } /** @@ -952,8 +943,7 @@ private void loadPlotData() { CSVReader reader = null; rawPlotData = new ArrayList<>(); try { - reader = new CSVReader(new InputStreamReader( - new FileInputStream(plotFile), Charset.defaultCharset().name())); + reader = new CSVReader(new InputStreamReader(new FileInputStream(plotFile), Charset.defaultCharset())); // throw away 2 header lines reader.readNext(); reader.readNext(); @@ -984,8 +974,7 @@ private void savePlotData() { File plotFile = new File(project.getRootDir(), getCsvFileName()); CSVWriter writer = null; try { - writer = new CSVWriter(new OutputStreamWriter( - new FileOutputStream(plotFile), Charset.defaultCharset().name())); + writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(plotFile), Charset.defaultCharset())); // write 2 header lines String[] header1 = new String[] {Messages.Plot_Title(), this.getTitle()}; String[] header2 = new String[] { diff --git a/src/main/java/hudson/plugins/plot/PlotAction.java b/src/main/java/hudson/plugins/plot/PlotAction.java index 619bf108..074008d0 100644 --- a/src/main/java/hudson/plugins/plot/PlotAction.java +++ b/src/main/java/hudson/plugins/plot/PlotAction.java @@ -11,8 +11,8 @@ import java.util.List; import org.apache.commons.collections.CollectionUtils; import org.kohsuke.stapler.StaplerProxy; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerRequest2; +import org.kohsuke.stapler.StaplerResponse2; /** * Project action to display plots. @@ -78,7 +78,7 @@ public String getUrlGroup(String originalGroup) { } // called from href created in PlotAction/index.jelly - public PlotReport getDynamic(String group, StaplerRequest req, StaplerResponse rsp) throws IOException { + public PlotReport getDynamic(String group, StaplerRequest2 req, StaplerResponse2 rsp) throws IOException { return new PlotReport( project, publisher.urlGroupToOriginalGroup(getUrlGroup(group)), publisher.getPlots(getUrlGroup(group))); } diff --git a/src/main/java/hudson/plugins/plot/PlotBuilder.java b/src/main/java/hudson/plugins/plot/PlotBuilder.java index 9b1883a3..c5bd73bb 100644 --- a/src/main/java/hudson/plugins/plot/PlotBuilder.java +++ b/src/main/java/hudson/plugins/plot/PlotBuilder.java @@ -12,24 +12,24 @@ import hudson.tasks.BuildStepDescriptor; import hudson.tasks.Builder; import hudson.util.FormValidation; +import jakarta.servlet.ServletException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import javax.servlet.ServletException; import jenkins.tasks.SimpleBuildStep; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * Plot {@link Builder} class for pipeline. *

* When the user configures the project and enables this builder, - * {@link DescriptorImpl#newInstance(StaplerRequest)} is invoked + * {@link DescriptorImpl#newInstance(StaplerRequest2, JSONObject)} is invoked * and a new {@link PlotBuilder} is created. * The created instance is persisted to the project configuration XML by using XStream, * so this allows you to use instance fields (like {@link #group}) to remember the configuration. @@ -296,7 +296,7 @@ public DescriptorImpl() { } public String getCsvFileName() { - return "plot-" + UUID.randomUUID().toString() + ".csv"; + return "plot-" + UUID.randomUUID() + ".csv"; } public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException { @@ -323,7 +323,7 @@ public String getDisplayName() { } @Override - public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + public boolean configure(StaplerRequest2 req, JSONObject formData) throws FormException { save(); return super.configure(req, formData); } diff --git a/src/main/java/hudson/plugins/plot/PlotCategoryDataset.java b/src/main/java/hudson/plugins/plot/PlotCategoryDataset.java index 75ff9a82..e7f23fa1 100644 --- a/src/main/java/hudson/plugins/plot/PlotCategoryDataset.java +++ b/src/main/java/hudson/plugins/plot/PlotCategoryDataset.java @@ -5,6 +5,7 @@ */ package hudson.plugins.plot; +import java.io.Serial; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -20,6 +21,7 @@ * @author Nigel Daley */ public class PlotCategoryDataset extends AbstractDataset implements CategoryDataset { + @Serial private static final long serialVersionUID = 9215482265757674967L; private static class DataElement { @@ -171,7 +173,7 @@ public Number getValue(Comparable rowKey, Comparable columnKey) { if (rowIndex == -1 || data.get(rowIndex) == null) { return null; } - DataElement element = (DataElement) data.get(rowIndex).get(columnKey); + DataElement element = data.get(rowIndex).get(columnKey); if (element == null) { return null; } @@ -217,7 +219,7 @@ public void setValue(Number value, String url, Comparable rowKey, Comparable col if (rowIndex == -1) { rowKeys.add(rowKey); rowIndex = rowKeys.size() - 1; - data.add(new HashMap()); + data.add(new HashMap<>()); } if (!columnKeys.contains(columnKey)) { boolean added = false; diff --git a/src/main/java/hudson/plugins/plot/PlotDescriptor.java b/src/main/java/hudson/plugins/plot/PlotDescriptor.java index a77984fd..88fffa27 100644 --- a/src/main/java/hudson/plugins/plot/PlotDescriptor.java +++ b/src/main/java/hudson/plugins/plot/PlotDescriptor.java @@ -12,7 +12,7 @@ import net.sf.json.JSONObject; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.QueryParameter; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * The Descriptor for the plot configuration Extension @@ -41,7 +41,7 @@ public boolean isApplicable(Class 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 { PlotPublisher publisher = new PlotPublisher(); for (Object data : SeriesFactory.getArray(formData.get("plots"))) { publisher.addPlot(bindPlot((JSONObject) data, req)); @@ -49,7 +49,7 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData) throws For 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; diff --git a/src/main/java/hudson/plugins/plot/PlotPublisher.java b/src/main/java/hudson/plugins/plot/PlotPublisher.java index d614c455..a2e00d01 100644 --- a/src/main/java/hudson/plugins/plot/PlotPublisher.java +++ b/src/main/java/hudson/plugins/plot/PlotPublisher.java @@ -68,7 +68,7 @@ public String urlGroupToOriginalGroup(String urlGroup) { * Returns all group names as the original user specified strings. */ public List getOriginalGroups() { - List originalGroups = new ArrayList(); + List originalGroups = new ArrayList<>(); for (String urlGroup : groupMap.keySet()) { originalGroups.add(urlGroupToOriginalGroup(urlGroup)); } @@ -130,7 +130,7 @@ public List getPlots() { */ public List getPlots(String urlGroup) { List p = groupMap.get(urlGroup); - return (p != null) ? p : new ArrayList(); + return (p != null) ? p : new ArrayList<>(); } /** diff --git a/src/main/java/hudson/plugins/plot/PlotReport.java b/src/main/java/hudson/plugins/plot/PlotReport.java index 52ddef03..b0ca61be 100644 --- a/src/main/java/hudson/plugins/plot/PlotReport.java +++ b/src/main/java/hudson/plugins/plot/PlotReport.java @@ -21,8 +21,8 @@ import java.util.logging.Logger; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerRequest2; +import org.kohsuke.stapler.StaplerResponse2; /** * Represents a plot report for a single group of plots. @@ -98,7 +98,7 @@ public String getPlotDescription(int i) { } // called from PlotReport/index.jelly - public void doGetPlot(StaplerRequest req, StaplerResponse rsp) { + public void doGetPlot(StaplerRequest2 req, StaplerResponse2 rsp) { String i = req.getParameter("index"); Plot plot = getPlot(i); try { @@ -109,7 +109,7 @@ public void doGetPlot(StaplerRequest req, StaplerResponse rsp) { } // called from PlotReport/index.jelly - public void doGetPlotMap(StaplerRequest req, StaplerResponse rsp) { + public void doGetPlotMap(StaplerRequest2 req, StaplerResponse2 rsp) { String i = req.getParameter("index"); Plot plot = getPlot(i); try { @@ -143,8 +143,7 @@ public List> getTable(int i) { } CSVReader reader = null; try { - reader = new CSVReader(new InputStreamReader( - new FileInputStream(plotFile), Charset.defaultCharset().name())); + reader = new CSVReader(new InputStreamReader(new FileInputStream(plotFile), Charset.defaultCharset())); // throw away 2 header lines reader.readNext(); reader.readNext(); diff --git a/src/main/java/hudson/plugins/plot/PropertiesSeries.java b/src/main/java/hudson/plugins/plot/PropertiesSeries.java index 671651a7..5cfc0523 100644 --- a/src/main/java/hudson/plugins/plot/PropertiesSeries.java +++ b/src/main/java/hudson/plugins/plot/PropertiesSeries.java @@ -21,13 +21,13 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * @author Allen Reese */ public class PropertiesSeries extends Series { - private static final transient Logger LOGGER = Logger.getLogger(PropertiesSeries.class.getName()); + private static final Logger LOGGER = Logger.getLogger(PropertiesSeries.class.getName()); @DataBoundConstructor public PropertiesSeries(String file, String label) { @@ -66,7 +66,7 @@ public List loadSeries(FilePath workspaceRootDir, int buildNumber, Pr "Not creating point with null values: y=" + yvalue + " label=" + getLabel() + " url=" + url); return null; } - List series = new ArrayList(); + List series = new ArrayList<>(); series.add(new PlotPoint(yvalue, url, getLabel())); return series; } catch (Exception e) { @@ -90,7 +90,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); } } diff --git a/src/main/java/hudson/plugins/plot/Series.java b/src/main/java/hudson/plugins/plot/Series.java index 982419e2..acc41d20 100644 --- a/src/main/java/hudson/plugins/plot/Series.java +++ b/src/main/java/hudson/plugins/plot/Series.java @@ -15,7 +15,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.json.JSONObject; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * Represents a plot data series configuration. @@ -24,8 +24,8 @@ * @author Allen Reese */ public abstract class Series extends AbstractDescribableImpl { - private static final transient Pattern PAT_NAME = Pattern.compile("%name%"); - private static final transient Pattern PAT_INDEX = Pattern.compile("%index%"); + private static final Pattern PAT_NAME = Pattern.compile("%name%"); + private static final Pattern PAT_INDEX = Pattern.compile("%index%"); private static final Pattern PAT_BUILD_NUMBER = Pattern.compile("%build%"); /** @@ -144,7 +144,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); } } diff --git a/src/main/java/hudson/plugins/plot/SeriesFactory.java b/src/main/java/hudson/plugins/plot/SeriesFactory.java index 230ab416..c4fcc306 100644 --- a/src/main/java/hudson/plugins/plot/SeriesFactory.java +++ b/src/main/java/hudson/plugins/plot/SeriesFactory.java @@ -10,7 +10,7 @@ import java.util.List; import net.sf.json.JSONArray; import net.sf.json.JSONObject; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * This class creates a Series class based on the data source @@ -27,7 +27,7 @@ private SeriesFactory() {} * * @param formData JSON data for series */ - public static Series createSeries(JSONObject formData, StaplerRequest req) { + public static Series createSeries(JSONObject formData, StaplerRequest2 req) { String file = formData.getString("file"); formData = formData.getJSONObject("fileType"); formData.put("file", file); @@ -45,7 +45,7 @@ public static Series createSeries(JSONObject formData, StaplerRequest req) { return typeClass != null ? req.bindJSON(typeClass, formData) : null; } - public static List createSeriesList(Object data, StaplerRequest req) { + public static List createSeriesList(Object data, StaplerRequest2 req) { JSONArray list = getArray(data); List result = new ArrayList<>(); for (Object series : list) { diff --git a/src/main/java/hudson/plugins/plot/XMLSeries.java b/src/main/java/hudson/plugins/plot/XMLSeries.java index d3aa8665..ec81f0f9 100644 --- a/src/main/java/hudson/plugins/plot/XMLSeries.java +++ b/src/main/java/hudson/plugins/plot/XMLSeries.java @@ -14,7 +14,6 @@ import java.io.PrintStream; import java.util.ArrayDeque; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,7 +31,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -45,23 +44,27 @@ * @author Allen Reese */ public class XMLSeries extends Series { - private static final transient Logger LOGGER = Logger.getLogger(XMLSeries.class.getName()); + private static final Logger LOGGER = Logger.getLogger(XMLSeries.class.getName()); // Debugging hack, so I don't have to change FINE/INFO... - private static final transient Level DEFAULT_LOG_LEVEL = Level.INFO; + private static final Level DEFAULT_LOG_LEVEL = Level.INFO; - private static final transient Map Q_NAME_MAP; + private static final Map Q_NAME_MAP; /* Fill out the qName map for easy reference. */ static { - HashMap tempMap = new HashMap(); - tempMap.put("BOOLEAN", XPathConstants.BOOLEAN); - tempMap.put("NODE", XPathConstants.NODE); - tempMap.put("NODESET", XPathConstants.NODESET); - tempMap.put("NUMBER", XPathConstants.NUMBER); - tempMap.put("STRING", XPathConstants.STRING); - Q_NAME_MAP = Collections.unmodifiableMap(tempMap); + Q_NAME_MAP = Map.of( + "BOOLEAN", + XPathConstants.BOOLEAN, + "NODE", + XPathConstants.NODE, + "NODESET", + XPathConstants.NODESET, + "NUMBER", + XPathConstants.NUMBER, + "STRING", + XPathConstants.STRING); } /** @@ -142,7 +145,7 @@ private List coalesceTextnodesAsLabelsStrategy(NodeList nodeList, int for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (!parentNodeMap.containsKey(node.getParentNode())) { - parentNodeMap.put(node.getParentNode(), new ArrayList()); + parentNodeMap.put(node.getParentNode(), new ArrayList<>()); } parentNodeMap.get(node.getParentNode()).add(node); } @@ -243,8 +246,7 @@ public List loadSeries(FilePath workspaceRootDir, int buildNumber, Pr addNodeToList(ret, (Node) xmlObject, buildNumber); } else { // otherwise we have a single type and can do a toString on it. - if (xmlObject instanceof NodeList) { - NodeList nl = (NodeList) xmlObject; + if (xmlObject instanceof NodeList nl) { if (LOGGER.isLoggable(DEFAULT_LOG_LEVEL)) { LOGGER.log(DEFAULT_LOG_LEVEL, "Number of nodes: " + nl.getLength()); @@ -371,7 +373,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); } } diff --git a/src/test/java/hudson/plugins/plot/CSVReaderTest.java b/src/test/java/hudson/plugins/plot/CSVReaderTest.java index 11d66a1e..03654dbc 100644 --- a/src/test/java/hudson/plugins/plot/CSVReaderTest.java +++ b/src/test/java/hudson/plugins/plot/CSVReaderTest.java @@ -58,7 +58,7 @@ public void testCSVReader() { int lineNum = 0; while ((nextLine = csvReader.readNext()) != null) { // for some reason csv reader returns an empty line sometimes. - if (nextLine.length == 1 && nextLine[0].length() == 0) { + if (nextLine.length == 1 && nextLine[0].isEmpty()) { break; } diff --git a/src/test/java/hudson/plugins/plot/CSVSeriesTest.java b/src/test/java/hudson/plugins/plot/CSVSeriesTest.java index 11de375f..4ef43e44 100644 --- a/src/test/java/hudson/plugins/plot/CSVSeriesTest.java +++ b/src/test/java/hudson/plugins/plot/CSVSeriesTest.java @@ -40,8 +40,8 @@ public class CSVSeriesTest extends SeriesTestCase { @Test public void testCSVSeriesWithNullExclusionValuesSetsDisplayTableFlag() { CSVSeries series; - for (int index = 0; index < FILES.length; index++) { - series = new CSVSeries(FILES[index], null, null, null, true); + for (String file : FILES) { + series = new CSVSeries(file, null, null, null, true); assertTrue(series.getDisplayTableFlag()); } } @@ -55,7 +55,7 @@ public void testCSVSeriesWithNoExclusions() { try { columns = getNumColumns(workspaceRootDir, FILES[index]); } catch (IOException | InterruptedException e) { - fail("Exception " + e.toString()); + fail("Exception " + e); } assertEquals(COLUMNS[index], columns); @@ -63,7 +63,7 @@ public void testCSVSeriesWithNoExclusions() { // Create a new CSV series. CSVSeries series = new CSVSeries(FILES[index], "http://localhost:8080/%name%/%index%/", "OFF", "", false); - LOGGER.info("Created series " + series.toString()); + LOGGER.info("Created series " + series); // test the basic subclass properties. testSeries(series, FILES[index], "", "csv"); @@ -94,7 +94,7 @@ public void testCSVSeriesIncludeOnlyLastColumn() { LAST_COLUMN_NAME[index], false); - LOGGER.info("Created series " + series.toString()); + LOGGER.info("Created series " + series); // load the series. List points = series.loadSeries(workspaceRootDir, 0, System.out); @@ -113,7 +113,7 @@ public void testCSVSeriesWithTrailingSemicolonDoesntCreateExtraneousPoint() { // Create a new CSV series. CSVSeries series = new CSVSeries(file, "http://localhost:8080/%name%/%index%/", "OFF", "", false); - LOGGER.info("Created series " + series.toString()); + LOGGER.info("Created series " + series); // test the basic subclass properties. testSeries(series, file, "", "csv"); diff --git a/src/test/java/hudson/plugins/plot/PlotBuildActionTest.java b/src/test/java/hudson/plugins/plot/PlotBuildActionTest.java index 2963582a..3f2f1c32 100644 --- a/src/test/java/hudson/plugins/plot/PlotBuildActionTest.java +++ b/src/test/java/hudson/plugins/plot/PlotBuildActionTest.java @@ -3,13 +3,11 @@ import static org.junit.Assert.fail; import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; -import com.thoughtworks.xstream.converters.reflection.ReflectionProvider; import hudson.model.Run; import java.util.ArrayList; import java.util.ConcurrentModificationException; import java.util.List; import java.util.Random; -import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -60,33 +58,27 @@ private void simulateConcurrentModificationException( List> tasks, final CountDownLatch latch) { for (int i = 0; i < tasksCount; i++) { - FutureTask task = new FutureTask<>(new Callable() { - @Override - public Object call() throws Exception { - try { - Thread.sleep(new Random().nextInt(100)); - // using PureJavaReflectionProvider just because it's used in Jenkins - // close to "real world" - PureJavaReflectionProvider provider = new PureJavaReflectionProvider(); - provider.visitSerializableFields(plotBuildAction, new ReflectionProvider.Visitor() { - @Override - public void visit(String fieldName, Class fieldType, Class definedIn, Object value) { - if (value != null && value instanceof List) { - List plots = (List) value; - // simulate ConcurrentModificationException - for (Plot p : plots) { - if (plots.size() > 0) { - plots.remove(p); - } - } + FutureTask task = new FutureTask<>(() -> { + try { + Thread.sleep(new Random().nextInt(100)); + // using PureJavaReflectionProvider just because it's used in Jenkins + // close to "real world" + PureJavaReflectionProvider provider = new PureJavaReflectionProvider(); + provider.visitSerializableFields(plotBuildAction, (fieldName, fieldType, definedIn, value) -> { + if (value != null && value instanceof List) { + List plots = (List) value; + // simulate ConcurrentModificationException + for (Plot p : plots) { + if (!plots.isEmpty()) { + plots.remove(p); } } - }); - } finally { - latch.countDown(); - } - return null; + } + }); + } finally { + latch.countDown(); } + return null; }); tasks.add(task); executorService.submit(task); diff --git a/src/test/java/hudson/plugins/plot/SeriesTestCase.java b/src/test/java/hudson/plugins/plot/SeriesTestCase.java index ec50e22b..10138f2b 100644 --- a/src/test/java/hudson/plugins/plot/SeriesTestCase.java +++ b/src/test/java/hudson/plugins/plot/SeriesTestCase.java @@ -71,7 +71,7 @@ public void testPlotPoints(List points, int expected) { } catch (NumberFormatException nfe) { fail("loadSeries returned invalid yvalue " + points.get(i).getYvalue() + " at index " + i - + " Exception " + nfe.toString()); + + " Exception " + nfe); } } } diff --git a/src/test/java/hudson/plugins/plot/XMLSeriesTest.java b/src/test/java/hudson/plugins/plot/XMLSeriesTest.java index 569e584d..9c7fa1ba 100644 --- a/src/test/java/hudson/plugins/plot/XMLSeriesTest.java +++ b/src/test/java/hudson/plugins/plot/XMLSeriesTest.java @@ -63,10 +63,10 @@ public void testXMLSeries_WhenNodesHaveNoContent_ThenCoalesceForAttributes() { // load the series. List points = series.loadSeries(workspaceRootDir, 0, System.out); assertNotNull(points); - assertEquals(points.size(), 3); - assertEquals(points.get(0).getLabel(), "testOne"); - assertEquals(points.get(1).getLabel(), "testTwo"); - assertEquals(points.get(2).getLabel(), "testThree"); + assertEquals(3, points.size()); + assertEquals("testOne", points.get(0).getLabel()); + assertEquals("testTwo", points.get(1).getLabel()); + assertEquals("testThree", points.get(2).getLabel()); testPlotPoints(points, 3); } @@ -84,11 +84,11 @@ public void testXMLSeriesNodeset() { List points = series.loadSeries(workspaceRootDir, 0, System.out); assertNotNull(points); assertEquals(4, points.size()); - assertEquals(points.get(0).getLabel(), "testOne"); - assertEquals(points.get(1).getLabel(), "testTwo"); - assertEquals(points.get(2).getLabel(), "testThree"); - assertEquals(points.get(3).getLabel(), "testFour"); - assertEquals(points.get(3).getYvalue(), "1234.56"); + assertEquals("testOne", points.get(0).getLabel()); + assertEquals("testTwo", points.get(1).getLabel()); + assertEquals("testThree", points.get(2).getLabel()); + assertEquals("testFour", points.get(3).getLabel()); + assertEquals("1234.56", points.get(3).getYvalue()); testPlotPoints(points, 4); } @@ -106,8 +106,8 @@ public void testXMLSeries_WhenAllNodesAreNumeric_ThenPointsAreLabelledWithNodeNa List points = series.loadSeries(workspaceRootDir, 0, System.out); assertNotNull(points); assertEquals(2, points.size()); - assertEquals(points.get(0).getLabel(), "one"); - assertEquals(points.get(0).getYvalue(), "0.521"); + assertEquals("one", points.get(0).getLabel()); + assertEquals("0.521", points.get(0).getYvalue()); testPlotPoints(points, 2); } @@ -140,8 +140,8 @@ public void testXMLSeriesNode() { // load the series. List points = series.loadSeries(workspaceRootDir, 0, System.out); assertNotNull(points); - assertEquals(points.size(), 1); - assertEquals(Double.parseDouble(points.get(0).getYvalue()), 27d, 0); + assertEquals(1, points.size()); + assertEquals(27d, Double.parseDouble(points.get(0).getYvalue()), 0); testPlotPoints(points, 1); } From 0c63a96857312f39d818b060685a33a0db882eec Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Fri, 7 Feb 2025 10:26:06 -0700 Subject: [PATCH 2/4] Remove empty test Test with no statements is not useful --- .../hudson/plugins/plot/SeriesFactoryTest.java | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/test/java/hudson/plugins/plot/SeriesFactoryTest.java diff --git a/src/test/java/hudson/plugins/plot/SeriesFactoryTest.java b/src/test/java/hudson/plugins/plot/SeriesFactoryTest.java deleted file mode 100644 index b98f3f66..00000000 --- a/src/test/java/hudson/plugins/plot/SeriesFactoryTest.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. - * The copyrights to the contents of this file are licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php) - */ -package hudson.plugins.plot; - -import junit.framework.TestCase; - -/** - * Test a SeriesFactory verify it returns the corrected - * - * @author Allen Reese - */ -public class SeriesFactoryTest extends TestCase { - public void testSeriesFactory() {} -} From 30015861404f2d1053a082fcff2b499d39c804b6 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Fri, 7 Feb 2025 14:51:45 -0700 Subject: [PATCH 3/4] Retain transient modifier to not alter serialization --- src/main/java/hudson/plugins/plot/CSVSeries.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/hudson/plugins/plot/CSVSeries.java b/src/main/java/hudson/plugins/plot/CSVSeries.java index 2b0bafb1..986bf069 100644 --- a/src/main/java/hudson/plugins/plot/CSVSeries.java +++ b/src/main/java/hudson/plugins/plot/CSVSeries.java @@ -38,11 +38,11 @@ * @author Allen Reese */ public class CSVSeries extends Series { - private static final Logger LOGGER = Logger.getLogger(CSVSeries.class.getName()); + private static final transient Logger LOGGER = Logger.getLogger(CSVSeries.class.getName()); // Debugging hack, so I don't have to change FINE/INFO... - private static final Level DEFAULT_LOG_LEVEL = Level.FINEST; - private static final Pattern PAT_SEMICOLON_ENCLOSURE = Pattern.compile("\"(.*?)\""); - private static final Pattern PAT_COMMA = Pattern.compile(","); + private static final transient Level DEFAULT_LOG_LEVEL = Level.FINEST; + private static final transient Pattern PAT_SEMICOLON_ENCLOSURE = Pattern.compile("\"(.*?)\""); + private static final transient Pattern PAT_COMMA = Pattern.compile(","); public enum InclusionFlag { OFF, From 98e4c45f46a9493ca45ac4ff75293a964124dc7c Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Fri, 7 Feb 2025 15:05:07 -0700 Subject: [PATCH 4/4] Retain transient modifier to not alter serialization --- src/main/java/hudson/plugins/plot/Series.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/hudson/plugins/plot/Series.java b/src/main/java/hudson/plugins/plot/Series.java index acc41d20..f21f34aa 100644 --- a/src/main/java/hudson/plugins/plot/Series.java +++ b/src/main/java/hudson/plugins/plot/Series.java @@ -24,8 +24,8 @@ * @author Allen Reese */ public abstract class Series extends AbstractDescribableImpl { - private static final Pattern PAT_NAME = Pattern.compile("%name%"); - private static final Pattern PAT_INDEX = Pattern.compile("%index%"); + private static final transient Pattern PAT_NAME = Pattern.compile("%name%"); + private static final transient Pattern PAT_INDEX = Pattern.compile("%index%"); private static final Pattern PAT_BUILD_NUMBER = Pattern.compile("%build%"); /**