Commit 8f1f8dd6 authored by mnhock's avatar mnhock Committed by Andy Wilkinson

Use entrySet() rather than using keySet() and then calling get(key)

Closes gh-4813
parent 48d22f93
...@@ -21,6 +21,7 @@ import java.util.Collections; ...@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
...@@ -92,11 +93,11 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object> ...@@ -92,11 +93,11 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>
Map<?, HandlerMethod> methods = applicationContext Map<?, HandlerMethod> methods = applicationContext
.getBean(name, AbstractHandlerMethodMapping.class) .getBean(name, AbstractHandlerMethodMapping.class)
.getHandlerMethods(); .getHandlerMethods();
for (Object key : methods.keySet()) { for (Entry<?, HandlerMethod> method : methods.entrySet()) {
Map<String, String> map = new LinkedHashMap<String, String>(); Map<String, String> map = new LinkedHashMap<String, String>();
map.put("bean", name); map.put("bean", name);
map.put("method", methods.get(key).toString()); map.put("method", method.getValue().toString());
result.put(key.toString(), map); result.put( method.getKey().toString(), map);
} }
} }
} }
...@@ -107,11 +108,11 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object> ...@@ -107,11 +108,11 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>
if (applicationContext != null) { if (applicationContext != null) {
Map<String, AbstractUrlHandlerMapping> mappings = applicationContext Map<String, AbstractUrlHandlerMapping> mappings = applicationContext
.getBeansOfType(AbstractUrlHandlerMapping.class); .getBeansOfType(AbstractUrlHandlerMapping.class);
for (String name : mappings.keySet()) { for (Entry<String, AbstractUrlHandlerMapping> mapping : mappings.entrySet()) {
AbstractUrlHandlerMapping mapping = mappings.get(name); Map<String, Object> handlers = getHandlerMap(mapping.getValue());
Map<String, Object> handlers = getHandlerMap(mapping); for (Entry<String, Object> handler : handlers.entrySet()) {
for (String key : handlers.keySet()) { result.put(handler.getKey(),
result.put(key, Collections.singletonMap("bean", name)); Collections.singletonMap("bean", mapping.getKey()));
} }
} }
} }
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.endpoint.jmx; ...@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.endpoint.jmx;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
...@@ -241,8 +242,8 @@ public class EndpointMBeanExporter extends MBeanExporter ...@@ -241,8 +242,8 @@ public class EndpointMBeanExporter extends MBeanExporter
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (Object key : this.objectNameStaticProperties.keySet()) { for (Entry<Object, Object> name : this.objectNameStaticProperties.entrySet()) {
builder.append("," + key + "=" + this.objectNameStaticProperties.get(key)); builder.append("," + name.getKey() + "=" + name.getValue());
} }
return builder.toString(); return builder.toString();
} }
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -21,6 +21,7 @@ import java.util.Collections; ...@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.Servlet; import javax.servlet.Servlet;
...@@ -132,7 +133,8 @@ public class WebMvcAutoConfiguration { ...@@ -132,7 +133,8 @@ public class WebMvcAutoConfiguration {
@EnableConfigurationProperties({ WebMvcProperties.class, ResourceProperties.class }) @EnableConfigurationProperties({ WebMvcProperties.class, ResourceProperties.class })
public static class WebMvcAutoConfigurationAdapter extends WebMvcConfigurerAdapter { public static class WebMvcAutoConfigurationAdapter extends WebMvcConfigurerAdapter {
private static final Log logger = LogFactory.getLog(WebMvcConfigurerAdapter.class); private static final Log logger = LogFactory
.getLog(WebMvcConfigurerAdapter.class);
@Autowired @Autowired
private ResourceProperties resourceProperties = new ResourceProperties(); private ResourceProperties resourceProperties = new ResourceProperties();
...@@ -162,8 +164,8 @@ public class WebMvcAutoConfiguration { ...@@ -162,8 +164,8 @@ public class WebMvcAutoConfiguration {
@Override @Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
Map<String, MediaType> mediaTypes = this.mvcProperties.getMediaTypes(); Map<String, MediaType> mediaTypes = this.mvcProperties.getMediaTypes();
for (String extension : mediaTypes.keySet()) { for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
configurer.mediaType(extension, mediaTypes.get(extension)); configurer.mediaType(mediaType.getKey(), mediaType.getValue());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment