You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/12/11 13:16:40 UTC
[groovy] branch master updated: Trivial refactoring: avoid redundant method calls
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 332d943 Trivial refactoring: avoid redundant method calls
332d943 is described below
commit 332d943b5be3875b21db0ae75eb7e9fb05f1b9c3
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Dec 11 21:15:40 2021 +0800
Trivial refactoring: avoid redundant method calls
---
.../groovy-test/src/main/java/groovy/test/GroovyAssert.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java b/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java
index de6b958..bf701d0 100644
--- a/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java
+++ b/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java
@@ -296,20 +296,19 @@ public class GroovyAssert {
* @throws RuntimeException if no method could be found.
*/
private static Method findRunningJUnitTestMethod(Class caller) {
- final Class[] args = new Class[]{};
+ final Class<?>[] args = new Class<?>[]{};
// search the initial junit test
- final Throwable t = new Exception();
- for (int i = t.getStackTrace().length - 1; i >= 0; --i) {
- final StackTraceElement element = t.getStackTrace()[i];
+ final StackTraceElement[] stackTrace = new Exception().getStackTrace();
+ for (int i = stackTrace.length - 1; i >= 0; --i) {
+ final StackTraceElement element = stackTrace[i];
if (element.getClassName().equals(caller.getName())) {
try {
final Method m = caller.getMethod(element.getMethodName(), args);
if (isPublicTestMethod(m)) {
return m;
}
- }
- catch (final Exception ignore) {
+ } catch (Exception ignore) {
// can't access, ignore it
}
}