This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-validator.git
commit 8d98a3df5c85107b9471381fe90846b2d443f517 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Dec 1 09:18:50 2023 -0500 One new Spotbugs issue and one false positive --- src/conf/spotbugs-exclude-filter.xml | 8 ++++- .../apache/commons/validator/ValidatorAction.java | 35 ++++++++++------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index 91f2df29..ca6b09da 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -31,5 +31,11 @@ <Match> <Class name="~.*" /> <Bug pattern="EI_EXPOSE_REP2" /> - </Match> + </Match> + <!-- False positive? + High: Class org.apache.commons.validator.routines.CreditCardValidator$1 defines non-transient non-serializable instance field val$creditCardRanges [org.apache.commons.validator.routines.CreditCardValidator$1] In CreditCardValidator.java SE_BAD_FIELD --> + <Match> + <Class name="org.apache.commons.validator.routines.CreditCardValidator$1" /> + <Bug pattern="SE_BAD_FIELD" /> + </Match> </FindBugsFilter> diff --git a/src/main/java/org/apache/commons/validator/ValidatorAction.java b/src/main/java/org/apache/commons/validator/ValidatorAction.java index 0b2c42f2..78c7892c 100644 --- a/src/main/java/org/apache/commons/validator/ValidatorAction.java +++ b/src/main/java/org/apache/commons/validator/ValidatorAction.java @@ -580,28 +580,25 @@ public class ValidatorAction implements Serializable { if (classLoader == null) { classLoader = getClass().getClassLoader(); } - try (InputStream is = openInputStream(javaScriptFileName, classLoader)) { - if (is == null) { - getLog().debug(" Unable to read javascript name " + javaScriptFileName); - return null; + // BufferedReader closes InputStreamReader closes InputStream + final InputStream is = openInputStream(javaScriptFileName, classLoader); + if (is == null) { + getLog().debug(" Unable to read javascript name " + javaScriptFileName); + return null; + } + final StringBuilder buffer = new StringBuilder(); + // TODO encoding + try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { + String line = null; + while ((line = reader.readLine()) != null) { + buffer.append(line).append("\n"); } - final StringBuilder buffer = new StringBuilder(); - // TODO encoding - try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { - String line = null; - while ((line = reader.readLine()) != null) { - buffer.append(line).append("\n"); - } - } catch (final IOException e) { - getLog().error("Error reading JavaScript file.", e); + } catch (final IOException e) { + getLog().error("Error reading JavaScript file.", e); - } - final String function = buffer.toString(); - return function.isEmpty() ? null : function; - } catch (IOException e) { - getLog().error("Error closing stream to JavaScript file.", e); - return null; } + final String function = buffer.toString(); + return function.isEmpty() ? null : function; } /**