Favor Math.[min|max]() over handcrafted code
In line with the general trend toward favoring core JDK APIs for common tasks in Spring Framework 5.2, this commit replaces handcrafted statements with Math.min() and Math.max() were applicable.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,10 +37,7 @@ public abstract class TestAnnotationUtils {
|
||||
*/
|
||||
public static long getTimeout(Method method) {
|
||||
Timed timed = AnnotatedElementUtils.findMergedAnnotation(method, Timed.class);
|
||||
if (timed == null) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(0, timed.millis());
|
||||
return (timed == null ? 0 : Math.max(0, timed.millis()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -400,7 +400,7 @@ public class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner {
|
||||
*/
|
||||
protected long getJUnitTimeout(FrameworkMethod frameworkMethod) {
|
||||
Test test = frameworkMethod.getAnnotation(Test.class);
|
||||
return (test != null && test.timeout() > 0 ? test.timeout() : 0);
|
||||
return (test == null ? 0 : Math.max(0, test.timeout()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user