Skip to content

Commit 7d106ed

Browse files
authored
Merge pull request #1547 from aleksandy/cleanup
cleanup code
2 parents 0ea35f5 + b363e29 commit 7d106ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+209
-247
lines changed

framework/src/play/Invoker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ public void run() {
443443
if (!queue.isEmpty()) {
444444
for (Future<?> task : new HashSet<>(queue.keySet())) {
445445
if (task.isDone()) {
446-
executor.submit(queue.get(task));
447-
queue.remove(task);
446+
executor.submit(queue.remove(task));
448447
}
449448
}
450449
}

framework/src/play/Logger.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,7 @@ static boolean niceThrowable(org.apache.logging.log4j.Level level, Throwable e,
592592
StringWriter sw = new StringWriter();
593593

594594
// Better format for Play exceptions
595-
if (e instanceof PlayException) {
596-
PlayException playException = (PlayException) e;
595+
if (e instanceof PlayException playException) {
597596
PrintWriter errorOut = new PrintWriter(sw);
598597
errorOut.println("");
599598
errorOut.println("");

framework/src/play/cache/MemcachedImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public Map<String, Object> get(String[] keys) {
165165
} catch (Exception e) {
166166
future.cancel(false);
167167
}
168-
return Collections.<String, Object>emptyMap();
168+
return Collections.emptyMap();
169169
}
170170

171171
@Override

framework/src/play/classloading/BytecodeCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static byte[] getBytecode(String name, String source) {
6161
hash.append((char) read);
6262
offset++;
6363
}
64-
if (!hash(source).equals(hash.toString())) {
64+
if (!hash(source).contentEquals(hash)) {
6565
if (Logger.isTraceEnabled()) {
6666
Logger.trace("Bytecode too old (%s != %s)", hash, hash(source));
6767
}

framework/src/play/data/binding/Binder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ private static Object internalDirectBind(String name, Annotation[] annotations,
799799
return clazz.isPrimitive() ? false : null;
800800
}
801801

802-
if (value.equals("1") || value.toLowerCase().equals("on") || value.toLowerCase().equals("yes")) {
802+
if (value.equals("1") || value.equalsIgnoreCase("on") || value.equalsIgnoreCase("yes")) {
803803
return true;
804804
}
805805

framework/src/play/data/binding/Unbinder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private static void unbindMap(Map<String, Object> result, Object src, Class<?> s
7272
if (!isDirect(key.getClass())) {
7373
throw new UnsupportedOperationException("Unbind won't work with indirect map keys yet");
7474
}
75-
String paramKey = name + '.' + key.toString();
75+
String paramKey = name + '.' + key;
7676
Unbinder.unBind(result, entry.getValue(), paramKey, annotations);
7777
}
7878
}
@@ -118,8 +118,7 @@ private static void internalUnbind(Map<String, Object> result, Object src, Class
118118
for (Annotation annotation : annotations) {
119119
if (annotation.annotationType().equals(As.class)) {
120120
// Check the unbinder param first
121-
Class<? extends TypeUnbinder<?>> toInstantiate = (Class<? extends TypeUnbinder<?>>) ((As) annotation)
122-
.unbinder();
121+
Class<? extends TypeUnbinder<?>> toInstantiate = ((As) annotation).unbinder();
123122
if (!(toInstantiate.equals(As.DEFAULT.class))) {
124123
TypeUnbinder<?> myInstance = toInstantiate.getDeclaredConstructor().newInstance();
125124
isExtendedTypeBinder = myInstance.unBind(result, src, srcClazz, name, annotations);

framework/src/play/data/parsing/ApacheMultipartParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ private static String getUniqueId() {
482482

483483
@Override
484484
public String toString() {
485-
return "name=" + this.getName() + ", StoreLocation=" + String.valueOf(this.getStoreLocation()) + ", size=" + this.getSize()
485+
return "name=" + this.getName() + ", StoreLocation=" + this.getStoreLocation() + ", size=" + this.getSize()
486486
+ "bytes, " + "isFormField=" + isFormField() + ", FieldName=" + this.getFieldName();
487487
}
488488

framework/src/play/data/parsing/TextParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public Map<String, String[]> parse(InputStream is) {
1818
while ((b = is.read()) != -1) {
1919
os.write(b);
2020
}
21-
byte[] data = os.toByteArray();
22-
params.put("body", new String[] {new String(data, Http.Request.current().encoding)});
21+
params.put("body", new String[] {os.toString(Http.Request.current().encoding)});
2322
return params;
2423
} catch (Exception e) {
2524
throw new UnexpectedException(e);

framework/src/play/data/parsing/UrlEncodedParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Map<String, String[]> parse(InputStream is) {
5555
os.write( buffer, 0, bytesRead);
5656
}
5757

58-
String data = new String(os.toByteArray(), encoding);
58+
String data = os.toString(encoding);
5959
if (data.length() == 0) {
6060
//data is empty - can skip the rest
6161
return new HashMap<>(0);

framework/src/play/data/validation/EqualsCheck.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public boolean isSatisfied(Object validatedObject, Object value, OValContext con
3636
requireMessageVariablesRecreation();
3737
try {
3838
if (context != null) {
39-
if (context instanceof MethodParameterContext) {
40-
MethodParameterContext ctx = (MethodParameterContext) context;
39+
if (context instanceof MethodParameterContext ctx) {
4140
Method method = ctx.getMethod();
4241
String[] paramNames = Java.parameterNames(method);
4342
int index = -1;
@@ -60,8 +59,7 @@ public boolean isSatisfied(Object validatedObject, Object value, OValContext con
6059

6160

6261
}
63-
if (context instanceof FieldContext) {
64-
FieldContext ctx = (FieldContext) context;
62+
if (context instanceof FieldContext ctx) {
6563
try {
6664
Field otherField = ctx.getField().getDeclaringClass().getDeclaredField(to);
6765
otherKey = to;

0 commit comments

Comments
 (0)