[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [text] Fix Spotbugs issues.
From: ggregory () apache ! org
Date: 2018-09-30 0:41:36
Message-ID: a3becd06cf3e4559846c34b1726bd57f () git ! apache ! org
[Download RAW message or body]
Repository: commons-text
Updated Branches:
refs/heads/master 96651f6f3 -> 21ac2e356
Fix Spotbugs issues.
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/21ac2e35
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/21ac2e35
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/21ac2e35
Branch: refs/heads/master
Commit: 21ac2e356040c994fdc26f2f67b1ba7231ea44d9
Parents: 96651f6
Author: Gary Gregory <garydgregory@gmail.com>
Authored: Sat Sep 29 18:41:33 2018 -0600
Committer: Gary Gregory <garydgregory@gmail.com>
Committed: Sat Sep 29 18:41:33 2018 -0600
----------------------------------------------------------------------
.../java/org/apache/commons/text/lookup/Base64StringLookup.java | 3 ++-
.../org/apache/commons/text/lookup/ConstantStringLookup.java | 3 +--
.../org/apache/commons/text/lookup/PropertiesStringLookup.java | 5 ++++-
.../org/apache/commons/text/lookup/UrlDecoderStringLookup.java | 2 +-
.../org/apache/commons/text/lookup/UrlEncoderStringLookup.java | 2 +-
5 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/21ac2e35/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java \
b/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java index \
a4651bd..e1607a4 100644
--- a/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java
@@ -17,6 +17,7 @@
package org.apache.commons.text.lookup;
+import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
@@ -40,7 +41,7 @@ final class Base64StringLookup extends AbstractStringLookup {
@Override
public String lookup(final String key) {
- return new String(Base64.getDecoder().decode(key));
+ return new String(Base64.getDecoder().decode(key), \
StandardCharsets.ISO_8859_1); }
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/21ac2e35/src/main/java/org/apache/commons/text/lookup/ConstantStringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/ConstantStringLookup.java \
b/src/main/java/org/apache/commons/text/lookup/ConstantStringLookup.java index \
96e7855..466e471 100644
--- a/src/main/java/org/apache/commons/text/lookup/ConstantStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/ConstantStringLookup.java
@@ -120,8 +120,7 @@ class ConstantStringLookup extends AbstractStringLookup {
if (clazz == null) {
return null;
}
- final Field field = clazz.getField(fieldName);
- return field == null ? null : field.get(null);
+ return clazz.getField(fieldName).get(null);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-text/blob/21ac2e35/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java \
b/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java index \
6c6acc9..edae89a 100644
--- a/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java
@@ -17,6 +17,7 @@
package org.apache.commons.text.lookup;
+import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;
@@ -77,7 +78,9 @@ final class PropertiesStringLookup extends AbstractStringLookup {
final String propertyKey = substringAfter(key, "::");
try {
final Properties properties = new Properties();
- properties.load(Files.newInputStream(Paths.get(documentPath)));
+ try (final InputStream inputStream = \
Files.newInputStream(Paths.get(documentPath))) { + \
properties.load(inputStream); + }
return properties.getProperty(propertyKey);
} catch (final Exception e) {
throw IllegalArgumentExceptions.format(e, "Error looking up properties \
[%s] and key [%s].", documentPath,
http://git-wip-us.apache.org/repos/asf/commons-text/blob/21ac2e35/src/main/java/org/apache/commons/text/lookup/UrlDecoderStringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/UrlDecoderStringLookup.java \
b/src/main/java/org/apache/commons/text/lookup/UrlDecoderStringLookup.java index \
55a2807..8e4e369 100644
--- a/src/main/java/org/apache/commons/text/lookup/UrlDecoderStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/UrlDecoderStringLookup.java
@@ -46,7 +46,7 @@ final class UrlDecoderStringLookup extends AbstractStringLookup {
public String lookup(final String key) {
final String enc = StandardCharsets.UTF_8.name();
try {
- return new String(URLDecoder.decode(key, enc));
+ return URLDecoder.decode(key, enc);
} catch (final UnsupportedEncodingException e) {
throw IllegalArgumentExceptions.format(e, "%s: source=%s, encoding=%s", \
e, key, enc); }
http://git-wip-us.apache.org/repos/asf/commons-text/blob/21ac2e35/src/main/java/org/apache/commons/text/lookup/UrlEncoderStringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/UrlEncoderStringLookup.java \
b/src/main/java/org/apache/commons/text/lookup/UrlEncoderStringLookup.java index \
fdc2c1f..43ba870 100644
--- a/src/main/java/org/apache/commons/text/lookup/UrlEncoderStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/UrlEncoderStringLookup.java
@@ -45,7 +45,7 @@ final class UrlEncoderStringLookup extends AbstractStringLookup {
public String lookup(final String key) {
final String enc = StandardCharsets.UTF_8.name();
try {
- return new String(URLEncoder.encode(key, enc));
+ return URLEncoder.encode(key, enc);
} catch (final UnsupportedEncodingException e) {
throw IllegalArgumentExceptions.format(e, "%s: source=%s, encoding=%s", \
e, key, enc); }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic