Skip to content

Commit

Permalink
Apply "instanceof pattern matching" in spring-core-test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Mar 5, 2023
1 parent 56523d5 commit 9548101
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public String toString() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -98,7 +98,7 @@ private ErrorMessageFactory errorMessageForInvocation(RecordedInvocation invocat
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(),
Expand Down

0 comments on commit 9548101

Please sign in to comment.