Skip to content

Commit 4bd9566

Browse files
committed
Polishing
(cherry picked from commit 5e7a8b2)
1 parent 561511f commit 4bd9566

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

spring-web/src/test/java/org/springframework/web/method/ResolvableMethod.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.springframework.core.annotation.AnnotatedElementUtils;
4848
import org.springframework.core.annotation.AnnotationUtils;
4949
import org.springframework.core.annotation.SynthesizingMethodParameter;
50+
import org.springframework.lang.Nullable;
5051
import org.springframework.objenesis.ObjenesisException;
5152
import org.springframework.objenesis.SpringObjenesis;
5253
import org.springframework.util.Assert;
@@ -120,6 +121,7 @@
120121
* </pre>
121122
*
122123
* @author Rossen Stoyanchev
124+
* @since 5.0
123125
*/
124126
public class ResolvableMethod {
125127

@@ -133,7 +135,7 @@ public class ResolvableMethod {
133135

134136

135137
private ResolvableMethod(Method method) {
136-
Assert.notNull(method, "method is required");
138+
Assert.notNull(method, "Method is required");
137139
this.method = method;
138140
}
139141

@@ -202,14 +204,14 @@ public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotati
202204
return new ArgResolver().annotNotPresent(annotationTypes);
203205
}
204206

205-
206207
@Override
207208
public String toString() {
208209
return "ResolvableMethod=" + formatMethod();
209210
}
210211

212+
211213
private String formatMethod() {
212-
return (this.method().getName() +
214+
return (method().getName() +
213215
Arrays.stream(this.method.getParameters())
214216
.map(this::formatParameter)
215217
.collect(joining(",\n\t", "(\n\t", "\n)")));
@@ -246,7 +248,7 @@ private static ResolvableType toResolvableType(Class<?> type, ResolvableType gen
246248

247249

248250
/**
249-
* Main entry point providing access to a {@code ResolvableMethod} builder.
251+
* Create a {@code ResolvableMethod} builder for the given handler class.
250252
*/
251253
public static <T> Builder<T> on(Class<T> objectClass) {
252254
return new Builder<>(objectClass);
@@ -262,13 +264,11 @@ public static class Builder<T> {
262264

263265
private final List<Predicate<Method>> filters = new ArrayList<>(4);
264266

265-
266267
private Builder(Class<?> objectClass) {
267268
Assert.notNull(objectClass, "Class must not be null");
268269
this.objectClass = objectClass;
269270
}
270271

271-
272272
private void addFilter(String message, Predicate<Method> filter) {
273273
this.filters.add(new LabeledPredicate<>(message, filter));
274274
}
@@ -277,7 +277,7 @@ private void addFilter(String message, Predicate<Method> filter) {
277277
* Filter on methods with the given name.
278278
*/
279279
public Builder<T> named(String methodName) {
280-
addFilter("methodName=" + methodName, m -> m.getName().equals(methodName));
280+
addFilter("methodName=" + methodName, method -> method.getName().equals(methodName));
281281
return this;
282282
}
283283

@@ -384,7 +384,6 @@ public ResolvableMethod mockCall(Consumer<T> invoker) {
384384
return new ResolvableMethod(method);
385385
}
386386

387-
388387
// Build & resolve shortcuts...
389388

390389
/**
@@ -438,7 +437,6 @@ public MethodParameter resolveReturnType(ResolvableType returnType) {
438437
return returning(returnType).build().returnType();
439438
}
440439

441-
442440
@Override
443441
public String toString() {
444442
return "ResolvableMethod.Builder[\n" +
@@ -452,6 +450,7 @@ private String formatFilters() {
452450
}
453451
}
454452

453+
455454
/**
456455
* Predicate with a descriptive label.
457456
*/
@@ -461,7 +460,6 @@ private static class LabeledPredicate<T> implements Predicate<T> {
461460

462461
private final Predicate<T> delegate;
463462

464-
465463
private LabeledPredicate(String label, Predicate<T> delegate) {
466464
this.label = label;
467465
this.delegate = delegate;
@@ -494,14 +492,14 @@ public String toString() {
494492
}
495493
}
496494

495+
497496
/**
498497
* Resolver for method arguments.
499498
*/
500499
public class ArgResolver {
501500

502501
private final List<Predicate<MethodParameter>> filters = new ArrayList<>(4);
503502

504-
505503
@SafeVarargs
506504
private ArgResolver(Predicate<MethodParameter>... filter) {
507505
this.filters.addAll(Arrays.asList(filter));
@@ -593,17 +591,18 @@ private List<MethodParameter> applyFilters() {
593591
}
594592
}
595593

594+
596595
private static class MethodInvocationInterceptor
597596
implements org.springframework.cglib.proxy.MethodInterceptor, MethodInterceptor {
598597

599598
private Method invokedMethod;
600599

601-
602600
Method getInvokedMethod() {
603601
return this.invokedMethod;
604602
}
605603

606604
@Override
605+
@Nullable
607606
public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy) {
608607
if (ReflectionUtils.isObjectMethod(method)) {
609608
return ReflectionUtils.invokeMethod(method, object, args);
@@ -615,6 +614,7 @@ public Object intercept(Object object, Method method, Object[] args, MethodProxy
615614
}
616615

617616
@Override
617+
@Nullable
618618
public Object invoke(org.aopalliance.intercept.MethodInvocation inv) throws Throwable {
619619
return intercept(inv.getThis(), inv.getMethod(), inv.getArguments(), null);
620620
}

src/docs/asciidoc/core/core-aop.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,13 +2890,13 @@ container and once through the aspect.
28902890
[[aop-configurable-testing]]
28912891
==== Unit testing @Configurable objects
28922892

2893-
One of the goals of the `@Configurable` support is to enable independent unit testing of
2894-
domain objects without the difficulties associated with hard-coded lookups. If
2895-
`@Configurable` types have not been woven by AspectJ then the annotation has no affect
2893+
One of the goals of the `@Configurable` support is to enable independent unit testing
2894+
of domain objects without the difficulties associated with hard-coded lookups.
2895+
If `@Configurable` types have not been woven by AspectJ, the annotation has no affect
28962896
during unit testing, and you can simply set mock or stub property references in the
28972897
object under test and proceed as normal. If `@Configurable` types __have__ been woven by
28982898
AspectJ then you can still unit test outside of the container as normal, but you will
2899-
see a warning message each time that you construct an `@Configurable` object indicating
2899+
see a warning message each time that you construct a `@Configurable` object indicating
29002900
that it has not been configured by Spring.
29012901

29022902

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ The table below lists the available `HandlerExceptionResolver` implementations:
547547
codes based on the value in the annotation.
548548

549549
| `ExceptionHandlerExceptionResolver`
550-
| Resolves exceptions by invoking an `@ExceptionHandler` method in an `@Controller` or an
550+
| Resolves exceptions by invoking an `@ExceptionHandler` method in an `@Controller` or a
551551
`@ControllerAdvice` class. See <<mvc-ann-exceptionhandler,@ExceptionHandler methods>>.
552552
|===
553553

@@ -2660,7 +2660,7 @@ to the model:
26602660
===== Jackson JSONP
26612661

26622662
In order to enable http://en.wikipedia.org/wiki/JSONP[JSONP] support for `@ResponseBody`
2663-
and `ResponseEntity` methods, declare an `@ControllerAdvice` bean that extends
2663+
and `ResponseEntity` methods, declare a `@ControllerAdvice` bean that extends
26642664
`AbstractJsonpResponseBodyAdvice` as shown below where the constructor argument indicates
26652665
the JSONP query parameter name(s):
26662666

0 commit comments

Comments
 (0)