From 2f8ff5c1fb6a554db71334e6a355f2d595caaa99 Mon Sep 17 00:00:00 2001 From: Anna Karyakina Date: Fri, 10 Dec 2021 21:39:42 -0800 Subject: [PATCH] Make spotbugs happy --- .../fortify/plugin/jenkins/FortifyPlugin.java | 5 ++--- .../fortify/plugin/jenkins/TableAction.java | 18 +++++++++++++----- .../plugin/jenkins/bean/IssueFolderBean.java | 5 ++++- .../plugin/jenkins/steps/FortifyUpload.java | 8 +++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/fortify/plugin/jenkins/FortifyPlugin.java b/src/main/java/com/fortify/plugin/jenkins/FortifyPlugin.java index ec9310e..ad3b6f5 100644 --- a/src/main/java/com/fortify/plugin/jenkins/FortifyPlugin.java +++ b/src/main/java/com/fortify/plugin/jenkins/FortifyPlugin.java @@ -1443,9 +1443,8 @@ private String sanitizeUnicodeControls(String unsafeInput) { } String trimmed = unsafeInput.trim(); // we are limited with validation by the chars SSC supports for their application and version names - //String withoutUnicodeControls = trimmed.replaceAll("[\\p{C}&&\\p{Cntrl}]", "?"); - //return withoutUnicodeControls; - return trimmed; + String withoutUnicodeControls = trimmed.replaceAll("[\\p{C}&&\\p{Cntrl}]", "?"); + return withoutUnicodeControls; } private StringBuilder appVersionToJson(String appName, Map appVersions) { diff --git a/src/main/java/com/fortify/plugin/jenkins/TableAction.java b/src/main/java/com/fortify/plugin/jenkins/TableAction.java index 8a6a0d5..7d5803e 100644 --- a/src/main/java/com/fortify/plugin/jenkins/TableAction.java +++ b/src/main/java/com/fortify/plugin/jenkins/TableAction.java @@ -16,6 +16,7 @@ package com.fortify.plugin.jenkins; import java.io.IOException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.nio.charset.Charset; import java.util.ArrayList; @@ -516,11 +517,12 @@ public static class View implements Comparable, Serializable { private int page; private SortOrder sortOrder; private boolean sortDownNotUp; - private List issuesByFolder; - private Boolean needsUpdate; private int pageSize; private boolean showingAllNotNew; - private String SelectedGrouping; + private String selectedGrouping; + + private transient List issuesByFolder = null; + private transient Boolean needsUpdate = null; public View(IssueFolderBean descriptor, FortifyUpload manager, int pageNum) { this.folder = descriptor; @@ -530,13 +532,19 @@ public View(IssueFolderBean descriptor, FortifyUpload manager, int pageNum) { sortOrder = SortOrder.location; pageSize = manager.getIssuePageSize(); showingAllNotNew = true; - SelectedGrouping = "Category"; + selectedGrouping = "Category"; scheduleUpdate(); } + private void readObject(ObjectInputStream aInputStream) throws ClassNotFoundException, IOException { + needsUpdate = null; + issuesByFolder = null; + aInputStream.defaultReadObject(); + } + @JavaScriptMethod public String getSelectedGrouping() { - return SelectedGrouping; + return selectedGrouping; } @JavaScriptMethod diff --git a/src/main/java/com/fortify/plugin/jenkins/bean/IssueFolderBean.java b/src/main/java/com/fortify/plugin/jenkins/bean/IssueFolderBean.java index b429ef7..d636262 100644 --- a/src/main/java/com/fortify/plugin/jenkins/bean/IssueFolderBean.java +++ b/src/main/java/com/fortify/plugin/jenkins/bean/IssueFolderBean.java @@ -15,13 +15,16 @@ *******************************************************************************/ package com.fortify.plugin.jenkins.bean; +import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; import com.fortify.plugin.jenkins.FortifyPlugin; -public class IssueFolderBean implements Comparable { +public class IssueFolderBean implements Comparable, Serializable { + private static final long serialVersionUID = 9056328734887354382L; + public static final String ATTRIBUTE_VALUE_ALL = "All"; public static final String NAME_CRITICAL = "Critical"; diff --git a/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java b/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java index df9183c..65dda83 100644 --- a/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java +++ b/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java @@ -17,9 +17,11 @@ import java.io.File; import java.io.IOException; +import java.io.ObjectInputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; +import java.io.Serializable; import java.io.Writer; import java.nio.charset.Charset; import java.util.ArrayList; @@ -71,7 +73,8 @@ import net.sf.json.JSONException; import net.sf.json.JSONObject; -public class FortifyUpload extends FortifyStep { +public class FortifyUpload extends FortifyStep implements Serializable { + private static final long serialVersionUID = -8308672776705963290L; private boolean accessToProject = true; private int pageSize = 0; @@ -879,7 +882,7 @@ private T runWithFortifyClient(String token, FortifyClient.Command cmd) t } private static class Execution extends SynchronousNonBlockingStepExecution { - private transient FortifyUpload upload; + private FortifyUpload upload; protected Execution(FortifyUpload upload, StepContext context) { super(context); @@ -896,6 +899,5 @@ protected Void run() throws Exception { } private static final long serialVersionUID = 1L; - } }