Skip to content

Commit 0a42be2

Browse files
committed
Formatting [ci skip]
1 parent 19684fb commit 0a42be2

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set default behaviour, in case users don't have core.autocrlf set.
2+
* text=auto

src/main/java/org/mybatis/caches/memcached/MemcachedClientWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public MemcachedClientWrapper() {
6363
* @return the proper string representation.
6464
*/
6565
private String toKeyString(final Object key) {
66-
String keyString = configuration.getKeyPrefix() + StringUtils.sha1Hex(key.toString()); // issue #1, key too long
66+
String keyString = configuration.getKeyPrefix() + StringUtils.sha1Hex(key.toString()); // issue #1, key too long
6767
if (log.isDebugEnabled()) {
6868
log.debug("Object key '"
6969
+ key

src/main/java/org/mybatis/caches/memcached/StringUtils.java

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,64 +13,65 @@ public class StringUtils {
1313
private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
1414

1515
public static String join(Object[] array, String separator) {
16-
if (array == null) {
17-
return null;
18-
}
19-
int arraySize = array.length;
20-
StringBuilder buffer = new StringBuilder();
21-
22-
for (int i = 0; i < arraySize; i++) {
23-
if (i > 0) {
24-
buffer.append(separator);
25-
}
26-
if (array[i] != null) {
27-
buffer.append(array[i]);
28-
}
29-
}
30-
return buffer.toString();
16+
if (array == null) {
17+
return null;
18+
}
19+
int arraySize = array.length;
20+
StringBuilder buffer = new StringBuilder();
21+
22+
for (int i = 0; i < arraySize; i++) {
23+
if (i > 0) {
24+
buffer.append(separator);
25+
}
26+
if (array[i] != null) {
27+
buffer.append(array[i]);
28+
}
29+
}
30+
return buffer.toString();
3131
}
3232

3333
public static String md5Hex(String data) {
34-
if (data == null) {
35-
throw new IllegalArgumentException("data must not be null");
36-
}
34+
if (data == null) {
35+
throw new IllegalArgumentException("data must not be null");
36+
}
3737

38-
byte[] bytes = digest("MD5", data);
38+
byte[] bytes = digest("MD5", data);
3939

40-
return toHexString(bytes);
40+
return toHexString(bytes);
4141
}
4242

4343
public static String sha1Hex(String data) {
44-
if (data == null) {
45-
throw new IllegalArgumentException("data must not be null");
46-
}
44+
if (data == null) {
45+
throw new IllegalArgumentException("data must not be null");
46+
}
4747

48-
byte[] bytes = digest("SHA1", data);
48+
byte[] bytes = digest("SHA1", data);
4949

50-
return toHexString(bytes);
50+
return toHexString(bytes);
5151
}
5252

5353
private static String toHexString(byte[] bytes) {
54-
int l = bytes.length;
54+
int l = bytes.length;
5555

56-
char[] out = new char[l << 1];
56+
char[] out = new char[l << 1];
5757

58-
for (int i = 0, j = 0; i < l; i++) {
59-
out[j++] = DIGITS[(0xF0 & bytes[i]) >>> 4];
60-
out[j++] = DIGITS[0x0F & bytes[i]];
61-
}
58+
for (int i = 0, j = 0; i < l; i++) {
59+
out[j++] = DIGITS[(0xF0 & bytes[i]) >>> 4];
60+
out[j++] = DIGITS[0x0F & bytes[i]];
61+
}
6262

63-
return new String(out);
63+
return new String(out);
6464
}
6565

6666
private static byte[] digest(String algorithm, String data) {
67-
MessageDigest digest;
68-
try {
69-
digest = MessageDigest.getInstance(algorithm);
70-
} catch (NoSuchAlgorithmException e) {
71-
throw new RuntimeException(e);
72-
}
73-
74-
return digest.digest(data.getBytes());
67+
MessageDigest digest;
68+
try {
69+
digest = MessageDigest.getInstance(algorithm);
70+
} catch (NoSuchAlgorithmException e) {
71+
throw new RuntimeException(e);
72+
}
73+
74+
return digest.digest(data.getBytes());
7575
}
76-
}
76+
77+
}

0 commit comments

Comments
 (0)