Skip to content

Commit b02cdc7

Browse files
committed
Merge branch 'spring-projectsgh-4813'
2 parents 48d22f9 + 93ef795 commit b02cdc7

File tree

5 files changed

+51
-32
lines changed

5 files changed

+51
-32
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -21,6 +21,7 @@
2121
import java.util.LinkedHashMap;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.Map.Entry;
2425

2526
import org.springframework.aop.support.AopUtils;
2627
import org.springframework.beans.BeansException;
@@ -35,6 +36,7 @@
3536
* {@link Endpoint} to expose Spring MVC mappings.
3637
*
3738
* @author Dave Syer
39+
* @author Andy Wilkinson
3840
*/
3941
@ConfigurationProperties(prefix = "endpoints.mappings", ignoreUnknownFields = false)
4042
public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>>
@@ -83,20 +85,19 @@ public Map<String, Object> invoke() {
8385
return result;
8486
}
8587

88+
@SuppressWarnings("rawtypes")
8689
protected void extractMethodMappings(ApplicationContext applicationContext,
8790
Map<String, Object> result) {
8891
if (applicationContext != null) {
89-
for (String name : applicationContext
90-
.getBeansOfType(AbstractHandlerMethodMapping.class).keySet()) {
92+
for (Entry<String, AbstractHandlerMethodMapping> bean : applicationContext
93+
.getBeansOfType(AbstractHandlerMethodMapping.class).entrySet()) {
9194
@SuppressWarnings("unchecked")
92-
Map<?, HandlerMethod> methods = applicationContext
93-
.getBean(name, AbstractHandlerMethodMapping.class)
94-
.getHandlerMethods();
95-
for (Object key : methods.keySet()) {
95+
Map<?, HandlerMethod> methods = bean.getValue().getHandlerMethods();
96+
for (Entry<?, HandlerMethod> method : methods.entrySet()) {
9697
Map<String, String> map = new LinkedHashMap<String, String>();
97-
map.put("bean", name);
98-
map.put("method", methods.get(key).toString());
99-
result.put(key.toString(), map);
98+
map.put("bean", bean.getKey());
99+
map.put("method", method.getValue().toString());
100+
result.put(method.getKey().toString(), map);
100101
}
101102
}
102103
}
@@ -107,11 +108,11 @@ protected void extractHandlerMappings(ApplicationContext applicationContext,
107108
if (applicationContext != null) {
108109
Map<String, AbstractUrlHandlerMapping> mappings = applicationContext
109110
.getBeansOfType(AbstractUrlHandlerMapping.class);
110-
for (String name : mappings.keySet()) {
111-
AbstractUrlHandlerMapping mapping = mappings.get(name);
112-
Map<String, Object> handlers = getHandlerMap(mapping);
113-
for (String key : handlers.keySet()) {
114-
result.put(key, Collections.singletonMap("bean", name));
111+
for (Entry<String, AbstractUrlHandlerMapping> mapping : mappings.entrySet()) {
112+
Map<String, Object> handlers = getHandlerMap(mapping.getValue());
113+
for (Entry<String, Object> handler : handlers.entrySet()) {
114+
result.put(handler.getKey(),
115+
Collections.singletonMap("bean", mapping.getKey()));
115116
}
116117
}
117118
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -18,6 +18,7 @@
1818

1919
import java.util.HashSet;
2020
import java.util.Map;
21+
import java.util.Map.Entry;
2122
import java.util.Properties;
2223
import java.util.Set;
2324
import java.util.concurrent.locks.ReentrantLock;
@@ -241,8 +242,8 @@ private String getStaticNames() {
241242
}
242243
StringBuilder builder = new StringBuilder();
243244

244-
for (Object key : this.objectNameStaticProperties.keySet()) {
245-
builder.append("," + key + "=" + this.objectNameStaticProperties.get(key));
245+
for (Entry<Object, Object> name : this.objectNameStaticProperties.entrySet()) {
246+
builder.append("," + name.getKey() + "=" + name.getValue());
246247
}
247248
return builder.toString();
248249
}

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -21,6 +21,7 @@
2121
import java.util.Date;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.Map.Entry;
2425

2526
import javax.servlet.Servlet;
2627

@@ -132,7 +133,8 @@ public OrderedHttpPutFormContentFilter httpPutFormContentFilter() {
132133
@EnableConfigurationProperties({ WebMvcProperties.class, ResourceProperties.class })
133134
public static class WebMvcAutoConfigurationAdapter extends WebMvcConfigurerAdapter {
134135

135-
private static final Log logger = LogFactory.getLog(WebMvcConfigurerAdapter.class);
136+
private static final Log logger = LogFactory
137+
.getLog(WebMvcConfigurerAdapter.class);
136138

137139
@Autowired
138140
private ResourceProperties resourceProperties = new ResourceProperties();
@@ -162,8 +164,8 @@ public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
162164
@Override
163165
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
164166
Map<String, MediaType> mediaTypes = this.mvcProperties.getMediaTypes();
165-
for (String extension : mediaTypes.keySet()) {
166-
configurer.mediaType(extension, mediaTypes.get(extension));
167+
for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
168+
configurer.mediaType(mediaType.getKey(), mediaType.getValue());
167169
}
168170
}
169171

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ServiceCapabilitiesReportGenerator.java

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -23,11 +23,15 @@
2323
import java.util.Iterator;
2424
import java.util.List;
2525
import java.util.Map;
26+
import java.util.Map.Entry;
27+
import java.util.SortedSet;
28+
import java.util.TreeSet;
2629

2730
/**
2831
* A helper class generating a report from the meta-data of a particular service.
2932
*
3033
* @author Stephane Nicoll
34+
* @author Andy Wilkinson
3135
* @since 1.2.0
3236
*/
3337
class ServiceCapabilitiesReportGenerator {
@@ -104,11 +108,20 @@ private void reportAvailableProjectTypes(InitializrServiceMetadata metadata,
104108
StringBuilder report) {
105109
report.append("Available project types:" + NEW_LINE);
106110
report.append("------------------------" + NEW_LINE);
107-
List<String> typeIds = new ArrayList<String>(metadata.getProjectTypes().keySet());
108-
Collections.sort(typeIds);
109-
for (String typeId : typeIds) {
110-
ProjectType type = metadata.getProjectTypes().get(typeId);
111-
report.append(typeId + " - " + type.getName());
111+
SortedSet<Entry<String, ProjectType>> entries = new TreeSet<Entry<String, ProjectType>>(
112+
new Comparator<Entry<String, ProjectType>>() {
113+
114+
@Override
115+
public int compare(Entry<String, ProjectType> o1,
116+
Entry<String, ProjectType> o2) {
117+
return o1.getKey().compareTo(o2.getKey());
118+
}
119+
120+
});
121+
entries.addAll(metadata.getProjectTypes().entrySet());
122+
for (Entry<String, ProjectType> entry : entries) {
123+
ProjectType type = entry.getValue();
124+
report.append(entry.getKey() + " - " + type.getName());
112125
if (!type.getTags().isEmpty()) {
113126
reportTags(report, type);
114127
}

spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -19,6 +19,7 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.util.List;
22+
import java.util.Map.Entry;
2223
import java.util.Properties;
2324
import java.util.jar.JarEntry;
2425
import java.util.jar.JarOutputStream;
@@ -32,6 +33,7 @@
3233
* to be merged without losing any information.
3334
*
3435
* @author Dave Syer
36+
* @author Andy Wilkinson
3537
*/
3638
public class PropertiesMergingResourceTransformer implements ResourceTransformer {
3739

@@ -62,9 +64,9 @@ public void processResource(String resource, InputStream is,
6264
Properties properties = new Properties();
6365
properties.load(is);
6466
is.close();
65-
for (Object key : properties.keySet()) {
66-
String name = (String) key;
67-
String value = properties.getProperty(name);
67+
for (Entry<Object, Object> entry : properties.entrySet()) {
68+
String name = (String) entry.getKey();
69+
String value = (String) entry.getValue();
6870
String existing = this.data.getProperty(name);
6971
this.data.setProperty(name,
7072
existing == null ? value : existing + "," + value);

0 commit comments

Comments
 (0)