Skip to content

Commit f32e1bc

Browse files
committed
Polishing
1 parent 8df3fd3 commit f32e1bc

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,24 +46,23 @@ public BeanWiringInfo resolveWiringInfo(Object beanInstance) {
4646
}
4747

4848
/**
49-
* Build the BeanWiringInfo for the given Configurable annotation.
49+
* Build the {@link BeanWiringInfo} for the given {@link Configurable} annotation.
5050
* @param beanInstance the bean instance
5151
* @param annotation the Configurable annotation found on the bean class
5252
* @return the resolved BeanWiringInfo
5353
*/
5454
protected BeanWiringInfo buildWiringInfo(Object beanInstance, Configurable annotation) {
5555
if (!Autowire.NO.equals(annotation.autowire())) {
56+
// Autowiring by name or by type
5657
return new BeanWiringInfo(annotation.autowire().value(), annotation.dependencyCheck());
5758
}
59+
else if (!"".equals(annotation.value())) {
60+
// Explicitly specified bean name for bean definition to take property values from
61+
return new BeanWiringInfo(annotation.value(), false);
62+
}
5863
else {
59-
if (!"".equals(annotation.value())) {
60-
// explicitly specified bean name
61-
return new BeanWiringInfo(annotation.value(), false);
62-
}
63-
else {
64-
// default bean name
65-
return new BeanWiringInfo(getDefaultBeanName(beanInstance), true);
66-
}
64+
// Default bean name for bean definition to take property values from
65+
return new BeanWiringInfo(getDefaultBeanName(beanInstance), true);
6766
}
6867
}
6968

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
/**
3737
* A filter that wraps the {@link HttpServletResponse} and overrides its
3838
* {@link HttpServletResponse#encodeURL(String) encodeURL} method in order to
39-
* translate internal resource request URLs into public URL paths for external
40-
* use.
39+
* translate internal resource request URLs into public URL paths for external use.
4140
*
4241
* @author Jeremy Grelle
4342
* @author Rossen Stoyanchev
@@ -52,7 +51,8 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
5251

5352
@Override
5453
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
55-
throws IOException, ServletException {
54+
throws ServletException, IOException {
55+
5656
if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
5757
throw new ServletException("ResourceUrlEncodingFilter only supports HTTP requests");
5858
}
@@ -63,6 +63,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
6363
filterChain.doFilter(wrappedRequest, wrappedResponse);
6464
}
6565

66+
6667
private static class ResourceUrlEncodingRequestWrapper extends HttpServletRequestWrapper {
6768

6869
@Nullable
@@ -78,11 +79,11 @@ private static class ResourceUrlEncodingRequestWrapper extends HttpServletReques
7879
}
7980

8081
@Override
81-
public void setAttribute(String name, Object o) {
82-
super.setAttribute(name, o);
82+
public void setAttribute(String name, Object value) {
83+
super.setAttribute(name, value);
8384
if (ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR.equals(name)) {
84-
if(o instanceof ResourceUrlProvider) {
85-
initLookupPath((ResourceUrlProvider) o);
85+
if (value instanceof ResourceUrlProvider) {
86+
initLookupPath((ResourceUrlProvider) value);
8687
}
8788
}
8889

@@ -109,11 +110,11 @@ private void initLookupPath(ResourceUrlProvider urlProvider) {
109110
@Nullable
110111
public String resolveUrlPath(String url) {
111112
if (this.resourceUrlProvider == null) {
112-
logger.trace("ResourceUrlProvider not available via " +
113-
"request attribute ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR");
113+
logger.trace("ResourceUrlProvider not available via request attribute " +
114+
"ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR");
114115
return null;
115116
}
116-
if (url.startsWith(this.prefixLookupPath)) {
117+
if (this.indexLookupPath != null && url.startsWith(this.prefixLookupPath)) {
117118
int suffixIndex = getQueryParamsIndex(url);
118119
String suffix = url.substring(suffixIndex);
119120
String lookupPath = url.substring(this.indexLookupPath, suffixIndex);

0 commit comments

Comments
 (0)