Browse Source

Apply "instanceof pattern matching" in spring-core-test

See gh-30067
pull/30068/head
Sam Brannen 2 years ago
parent
commit
95481018d0
  1. 2
      spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java
  2. 4
      spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsInvocationsAssert.java

2
spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java

@ -181,7 +181,7 @@ public final class RecordedInvocation { @@ -181,7 +181,7 @@ public final class RecordedInvocation {
getHintType().hintClassName(), getMethodReference(), getArguments());
}
else {
Class<?> instanceType = (getInstance() instanceof Class<?>) ? getInstance() : getInstance().getClass();
Class<?> instanceType = (getInstance() instanceof Class<?> clazz) ? clazz : getInstance().getClass();
return "<%s> invocation of <%s> on type <%s> with arguments %s".formatted(
getHintType().hintClassName(), getMethodReference(), instanceType.getCanonicalName(), getArguments());
}

4
spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsInvocationsAssert.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -98,7 +98,7 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn @@ -98,7 +98,7 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn
invocation.getArguments(), formatStackTrace(invocation.getStackFrames()));
}
else {
Class<?> instanceType = (invocation.getInstance() instanceof Class<?>) ? invocation.getInstance() : invocation.getInstance().getClass();
Class<?> instanceType = (invocation.getInstance() instanceof Class<?> clazz) ? clazz : invocation.getInstance().getClass();
return new BasicErrorMessageFactory("%nMissing <%s> for invocation <%s> on type <%s> %nwith arguments %s.%nStacktrace:%n<%s>",
invocation.getHintType().hintClassName(), invocation.getMethodReference(),
instanceType, invocation.getArguments(),

Loading…
Cancel
Save