Skip to content

Commit fdde32b

Browse files
committed
Simplify internals
1 parent e3d2307 commit fdde32b

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

commons-vfs2/src/main/java/org/apache/commons/vfs2/UserAuthenticationData.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
*/
1717
package org.apache.commons.vfs2;
1818

19-
import java.util.Arrays;
2019
import java.util.Map;
2120
import java.util.Objects;
2221
import java.util.TreeMap;
2322

23+
import org.apache.commons.lang3.ArrayFill;
24+
2425
/**
2526
* Contains various authentication data.
2627
*/
@@ -103,13 +104,9 @@ public UserAuthenticationData() {
103104
public void cleanup() {
104105
// step 1: nullify character buffers
105106
for (final char[] data : authenticationData.values()) {
106-
if (data == null) {
107-
continue;
108-
}
109-
110-
Arrays.fill(data, (char) 0);
107+
ArrayFill.fill(data, (char) 0);
111108
}
112-
// step 2: allow data itself to gc
109+
// step 2: allow data itself to GC
113110
authenticationData.clear();
114111
}
115112

commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public static UserAuthenticationData authenticate(final UserAuthenticator auth,
5151
if (auth == null) {
5252
return null;
5353
}
54-
5554
return auth.requestAuthentication(authenticatorTypes);
5655
}
5756

@@ -67,24 +66,20 @@ public static void cleanup(final UserAuthenticationData authData) {
6766
}
6867

6968
/**
70-
* Gets data of given type from the UserAuthenticationData or null if there is no data or data of this type
71-
* available.
69+
* Gets a copy of the data of a given type from the UserAuthenticationData or null if there is no data or data of this type available.
7270
*
73-
* @param data The UserAuthenticationData.
74-
* @param type The type of the element to retrieve.
71+
* @param data The UserAuthenticationData.
72+
* @param type The type of the element to retrieve.
7573
* @param overriddenValue The default value.
7674
* @return The data of the given type as a character array or null if the data is not available.
7775
*/
78-
public static char[] getData(final UserAuthenticationData data, final UserAuthenticationData.Type type,
79-
final char[] overriddenValue) {
76+
public static char[] getData(final UserAuthenticationData data, final UserAuthenticationData.Type type, final char[] overriddenValue) {
8077
if (overriddenValue != null) {
8178
return overriddenValue;
8279
}
83-
8480
if (data == null) {
8581
return null;
8682
}
87-
8883
return data.getData(type);
8984
}
9085

@@ -98,7 +93,6 @@ public static char[] toChar(final String string) {
9893
if (string == null) {
9994
return null;
10095
}
101-
10296
return string.toCharArray();
10397
}
10498

@@ -112,7 +106,6 @@ public static String toString(final char[] data) {
112106
if (data == null) {
113107
return null;
114108
}
115-
116109
return new String(data);
117110
}
118111

0 commit comments

Comments
 (0)