Skip to content

Commit a94813f

Browse files
authored
Merge pull request #17 from kinow/minor-improvements
Minor improvements
2 parents 477db01 + 680a648 commit a94813f

16 files changed

Lines changed: 48 additions & 42 deletions

src/main/java/org/apache/commons/codec/Resources.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121

2222
/**
2323
* Consider this class package private. Helps load resources.
24-
*
24+
*
2525
* @since 1.12
2626
*/
2727
public class Resources {
2828

2929
/**
3030
* Opens the given named resource from the given class.
31-
*
31+
*
3232
* @param name The resource name.
3333
* @return An input stream.
3434
*/

src/main/java/org/apache/commons/codec/digest/B64.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
package org.apache.commons.codec.digest;
1818

19-
import java.security.NoSuchAlgorithmException;
2019
import java.security.SecureRandom;
2120
import java.util.Random;
2221

src/main/java/org/apache/commons/codec/digest/Crypt.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ public static String crypt(final byte[] keyBytes) {
6363
* @param keyBytes
6464
* plaintext password
6565
* @param salt
66-
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt is generated for
67-
* you using {@link ThreadLocalRandom}; for more secure salts consider using {@link SecureRandom} to
66+
* real salt value without prefix or "rounds=". The salt may be null,
67+
* in which case a salt is generated for you using {@link ThreadLocalRandom};
68+
* for more secure salts consider using {@link SecureRandom} to
6869
* generate your own salts.
6970
* @return hash value
7071
* @throws IllegalArgumentException
@@ -155,9 +156,9 @@ public static String crypt(final String key) {
155156
* @param key
156157
* plaintext password as entered by the used
157158
* @param salt
158-
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt is generated for
159-
* you using {@link ThreadLocalRandom}; for more secure salts consider using {@link SecureRandom} to
160-
* generate your own salts.
159+
* real salt value without prefix or "rounds=". The salt may be null, in which case a
160+
* salt is generated for you using {@link ThreadLocalRandom}; for more secure salts
161+
* consider using {@link SecureRandom} to generate your own salts.
161162
* @return hash value, i.e. encrypted password including the salt string
162163
* @throws IllegalArgumentException
163164
* if the salt does not match the allowed pattern

src/main/java/org/apache/commons/codec/digest/DigestUtils.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ public static MessageDigest getSha256Digest() {
221221
*
222222
* @return An SHA3-224 digest instance.
223223
* @throws IllegalArgumentException
224-
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on Oracle Java 9 and greater.
224+
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on
225+
* Oracle Java 9 andgreater.
225226
* @see MessageDigestAlgorithms#SHA3_224
226227
* @since 1.12
227228
*/
@@ -234,7 +235,8 @@ public static MessageDigest getSha3_224Digest() {
234235
*
235236
* @return An SHA3-256 digest instance.
236237
* @throws IllegalArgumentException
237-
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on Oracle Java 9 and greater.
238+
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on
239+
* Oracle Java 9 and greater.
238240
* @see MessageDigestAlgorithms#SHA3_256
239241
* @since 1.12
240242
*/
@@ -247,7 +249,8 @@ public static MessageDigest getSha3_256Digest() {
247249
*
248250
* @return An SHA3-384 digest instance.
249251
* @throws IllegalArgumentException
250-
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on Oracle Java 9 and greater.
252+
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on
253+
* Oracle Java 9 and greater.
251254
* @see MessageDigestAlgorithms#SHA3_384
252255
* @since 1.12
253256
*/
@@ -260,7 +263,8 @@ public static MessageDigest getSha3_384Digest() {
260263
*
261264
* @return An SHA3-512 digest instance.
262265
* @throws IllegalArgumentException
263-
* when a {@link NoSuchAlgorithmException} is caught, which should not happen on Oracle Java 9 and greater.
266+
* when a {@link NoSuchAlgorithmException} is caught, which should not happen
267+
* on Oracle Java 9 and greater.
264268
* @see MessageDigestAlgorithms#SHA3_512
265269
* @since 1.12
266270
*/
@@ -273,8 +277,8 @@ public static MessageDigest getSha3_512Digest() {
273277
*
274278
* @return An SHA-384 digest instance.
275279
* @throws IllegalArgumentException
276-
* when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-384 is a
277-
* built-in algorithm
280+
* when a {@link NoSuchAlgorithmException} is caught, which should never happen
281+
* because SHA-384 is a built-in algorithm
278282
* @see MessageDigestAlgorithms#SHA_384
279283
*/
280284
public static MessageDigest getSha384Digest() {
@@ -286,8 +290,8 @@ public static MessageDigest getSha384Digest() {
286290
*
287291
* @return An SHA-512 digest instance.
288292
* @throws IllegalArgumentException
289-
* when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-512 is a
290-
* built-in algorithm
293+
* when a {@link NoSuchAlgorithmException} is caught, which should never happen
294+
* because SHA-512 is a built-in algorithm
291295
* @see MessageDigestAlgorithms#SHA_512
292296
*/
293297
public static MessageDigest getSha512Digest() {

src/main/java/org/apache/commons/codec/digest/Md5Crypt.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ public static String md5Crypt(final byte[] keyBytes, final String salt) {
238238
* @param keyBytes
239239
* plaintext string to hash.
240240
* @param salt
241-
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt is generated for
242-
* you using {@link ThreadLocalRandom}; for more secure salts consider using {@link SecureRandom} to
243-
* generate your own salts.
241+
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt
242+
* is generated for you using {@link ThreadLocalRandom}; for more secure salts consider
243+
* using {@link SecureRandom} to generate your own salts.
244244
* @param prefix
245245
* salt prefix
246246
* @return the hash value
@@ -262,9 +262,9 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St
262262
* @param keyBytes
263263
* plaintext string to hash.
264264
* @param salt
265-
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt is generated for
266-
* you using {@link ThreadLocalRandom}; for more secure salts consider using {@link SecureRandom} to
267-
* generate your own salts.
265+
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt
266+
* is generated for you using {@link ThreadLocalRandom}; for more secure salts consider
267+
* using {@link SecureRandom} to generate your own salts.
268268
* @param prefix
269269
* salt prefix
270270
* @param random

src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public static String sha256Crypt(final byte[] keyBytes) {
9999
* @param keyBytes
100100
* plaintext to hash
101101
* @param salt
102-
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt is generated for
103-
* you using {@link SecureRandom}. If one does not want to use {@link SecureRandom}, you can pass your
104-
* own {@link Random} in {@link #sha256Crypt(byte[], String, Random)}.
102+
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt
103+
* is generated for you using {@link SecureRandom}. If one does not want to use {@link SecureRandom},
104+
* you can pass your own {@link Random} in {@link #sha256Crypt(byte[], String, Random)}.
105105
* @return complete hash value including salt
106106
* @throws IllegalArgumentException
107107
* if the salt does not match the allowed pattern
@@ -597,9 +597,9 @@ public static String sha512Crypt(final byte[] keyBytes, String salt) {
597597
* @param keyBytes
598598
* plaintext to hash
599599
* @param salt
600-
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt is generated for
601-
* you using {@link ThreadLocalRandom}; for more secure salts consider using {@link SecureRandom} to
602-
* generate your own salts.
600+
* real salt value without prefix or "rounds=". The salt may be null, in which case a salt
601+
* is generated for you using {@link ThreadLocalRandom}; for more secure salts consider using
602+
* {@link SecureRandom} to generate your own salts.
603603
* @param random
604604
* the instance of {@link Random} to use for generating the salt. Consider using {@link SecureRandom}
605605
* or {@link ThreadLocalRandom}.

src/main/java/org/apache/commons/codec/language/ColognePhonetic.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ public String colognePhonetic(String text) {
383383
code = chr; // should not happen?
384384
}
385385

386-
if (code != CHAR_IGNORE && (lastCode != code && (code != '0' || lastCode == CHAR_FIRST_POS) || code < '0' || code > '8')) {
386+
if (code != CHAR_IGNORE &&
387+
(lastCode != code && (code != '0' || lastCode == CHAR_FIRST_POS) || code < '0' || code > '8')) {
387388
output.addRight(code);
388389
}
389390

src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ private String[] soundex(final String source, final boolean branching) {
501501
}
502502

503503
// use an EMPTY_LIST to avoid false positive warnings wrt potential null pointer access
504-
final List<Branch> nextBranches = branching ? new ArrayList<>() : Collections.EMPTY_LIST;
504+
final List<Branch> nextBranches = branching ? new ArrayList<Branch>() : Collections.<Branch>emptyList();
505505

506506
for (final Rule rule : rules) {
507507
if (rule.matches(inputContext)) {

src/main/java/org/apache/commons/codec/net/PercentCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class PercentCodec implements BinaryEncoder, BinaryDecoder {
4242
* The escape character used by the Percent-Encoding in order to introduce an encoded character.
4343
*/
4444

45-
private final byte ESCAPE_CHAR = '%';
45+
private static final byte ESCAPE_CHAR = '%';
4646

4747
/**
4848
* The bit set used to store the character that should be always encoded

src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ public String decode(final String sourceStr, final Charset sourceCharset) throws
463463
* @throws UnsupportedEncodingException
464464
* Thrown if Charset is not supported
465465
*/
466-
public String decode(final String sourceStr, final String sourceCharset) throws DecoderException, UnsupportedEncodingException {
466+
public String decode(final String sourceStr, final String sourceCharset)
467+
throws DecoderException, UnsupportedEncodingException {
467468
if (sourceStr == null) {
468469
return null;
469470
}

0 commit comments

Comments
 (0)