Skip to content

Commit 06cf698

Browse files
committed
Polish
1 parent 31c6281 commit 06cf698

File tree

6 files changed

+32
-26
lines changed

6 files changed

+32
-26
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private void addBeanTypeForNonAliasDefinition(String name) {
167167
&& !requiresEagerInit(beanDefinition.getFactoryBeanName())) {
168168
if (this.beanFactory.isFactoryBean(factoryName)) {
169169
Class<?> factoryBeanGeneric = getFactoryBeanGeneric(this.beanFactory,
170-
beanDefinition, name);
170+
beanDefinition);
171171
this.beanTypes.put(name, factoryBeanGeneric);
172172
this.beanTypes.put(factoryName,
173173
this.beanFactory.getType(factoryName));
@@ -216,35 +216,34 @@ private void updateTypesIfNecessary() {
216216
* generics in its method signature.
217217
* @param beanFactory the source bean factory
218218
* @param definition the bean definition
219-
* @param name the name of the bean
220219
* @return the generic type of the {@link FactoryBean} or {@code null}
221220
*/
222221
private Class<?> getFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
223-
BeanDefinition definition, String name) {
222+
BeanDefinition definition) {
224223
try {
225-
return doGetFactoryBeanGeneric(beanFactory, definition, name);
224+
return doGetFactoryBeanGeneric(beanFactory, definition);
226225
}
227226
catch (Exception ex) {
228227
return null;
229228
}
230229
}
231230

232231
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
233-
BeanDefinition definition, String name)
232+
BeanDefinition definition)
234233
throws Exception, ClassNotFoundException, LinkageError {
235234
if (StringUtils.hasLength(definition.getFactoryBeanName())
236235
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
237-
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
236+
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition);
238237
}
239238
if (StringUtils.hasLength(definition.getBeanClassName())) {
240-
return getDirectFactoryBeanGeneric(beanFactory, definition, name);
239+
return getDirectFactoryBeanGeneric(beanFactory, definition);
241240
}
242241
return null;
243242
}
244243

245244
private Class<?> getConfigurationClassFactoryBeanGeneric(
246-
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
247-
String name) throws Exception {
245+
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
246+
throws Exception {
248247
Method method = getFactoryMethod(beanFactory, definition);
249248
Class<?> generic = ResolvableType.forMethodReturnType(method)
250249
.as(FactoryBean.class).resolveGeneric();
@@ -305,8 +304,8 @@ private boolean hasMatchingParameterTypes(Method candidate, Method current) {
305304
}
306305

307306
private Class<?> getDirectFactoryBeanGeneric(
308-
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
309-
String name) throws ClassNotFoundException, LinkageError {
307+
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
308+
throws ClassNotFoundException, LinkageError {
310309
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
311310
beanFactory.getBeanClassLoader());
312311
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfiguration.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-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.
@@ -20,7 +20,7 @@
2020
import java.net.URL;
2121
import java.util.List;
2222

23-
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.beans.factory.ObjectProvider;
2424
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2525
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2626
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -62,12 +62,16 @@ public class LocalDevToolsAutoConfiguration {
6262
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
6363
static class LiveReloadConfiguration {
6464

65-
@Autowired
6665
private DevToolsProperties properties;
6766

68-
@Autowired(required = false)
6967
private LiveReloadServer liveReloadServer;
7068

69+
LiveReloadConfiguration(DevToolsProperties properties,
70+
ObjectProvider<LiveReloadServer> liveReloadServer) {
71+
this.properties = properties;
72+
this.liveReloadServer = liveReloadServer.getIfAvailable();
73+
}
74+
7175
@Bean
7276
@RestartScope
7377
@ConditionalOnMissingBean
@@ -102,8 +106,11 @@ public OptionalLiveReloadServer optionalLiveReloadServer() {
102106
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
103107
static class RestartConfiguration {
104108

105-
@Autowired
106-
private DevToolsProperties properties;
109+
private final DevToolsProperties properties;
110+
111+
RestartConfiguration(DevToolsProperties properties) {
112+
this.properties = properties;
113+
}
107114

108115
@EventListener
109116
public void onClassPathChanged(ClassPathChangedEvent event) {

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-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.
@@ -80,15 +80,15 @@ class Connection {
8080
public void run() throws Exception {
8181
if (this.header.contains("Upgrade: websocket")
8282
&& this.header.contains("Sec-WebSocket-Version: 13")) {
83-
runWebSocket(this.header);
83+
runWebSocket();
8484
}
8585
if (this.header.contains("GET /livereload.js")) {
8686
this.outputStream.writeHttp(getClass().getResourceAsStream("livereload.js"),
8787
"text/javascript");
8888
}
8989
}
9090

91-
private void runWebSocket(String header) throws Exception {
91+
private void runWebSocket() throws Exception {
9292
String accept = getWebsocketAcceptResponse();
9393
this.outputStream.writeHeaders("HTTP/1.1 101 Switching Protocols",
9494
"Upgrade: websocket", "Connection: Upgrade",

spring-boot-test/src/test/java/org/springframework/boot/test/json/JsonContentTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-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.
@@ -60,6 +60,7 @@ public void createWhenTypeIsNullShouldCreateContent() throws Exception {
6060
assertThat(content).isNotNull();
6161
}
6262

63+
@SuppressWarnings("deprecation")
6364
@Test
6465
public void assertThatShouldReturnJsonContentAssert() throws Exception {
6566
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),

spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void start() throws EmbeddedServletContainerException {
208208
addPreviouslyRemovedConnectors();
209209
Connector connector = this.tomcat.getConnector();
210210
if (connector != null && this.autoStart) {
211-
startConnector(connector);
211+
performDeferredLoadOnStartup();
212212
}
213213
checkThatConnectorsHaveStarted();
214214
this.started = true;
@@ -281,7 +281,7 @@ private void stopProtocolHandler(Connector connector) {
281281
}
282282
}
283283

284-
private void startConnector(Connector connector) {
284+
private void performDeferredLoadOnStartup() {
285285
try {
286286
for (Container child : this.tomcat.getHost().findChildren()) {
287287
if (child instanceof TomcatEmbeddedContext) {

spring-boot/src/main/java/org/springframework/boot/env/PropertySourcesLoader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public PropertySource<?> load(Resource resource, String group, String name,
127127
if (canLoadFileExtension(loader, resource)) {
128128
PropertySource<?> specific = loader.load(sourceName, resource,
129129
profile);
130-
addPropertySource(group, specific, profile);
130+
addPropertySource(group, specific);
131131
return specific;
132132
}
133133
}
@@ -154,8 +154,7 @@ private boolean canLoadFileExtension(PropertySourceLoader loader, Resource resou
154154
return false;
155155
}
156156

157-
private void addPropertySource(String basename, PropertySource<?> source,
158-
String profile) {
157+
private void addPropertySource(String basename, PropertySource<?> source) {
159158

160159
if (source == null) {
161160
return;

0 commit comments

Comments
 (0)