Simplify iteration over maps

Closes gh-23053
This commit is contained in:
Сергей Цыпанов 2019-05-29 19:00:34 +03:00 committed by Sam Brannen
parent 5b04b04b69
commit aaeabc3c85
3 changed files with 8 additions and 8 deletions

View File

@ -92,10 +92,11 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
logger.debug("Failed to set JMSType - skipping", ex); logger.debug("Failed to set JMSType - skipping", ex);
} }
} }
Set<String> headerNames = headers.keySet(); Set<Map.Entry<String, Object>> entries = headers.entrySet();
for (String headerName : headerNames) { for (Map.Entry<String, Object> entry : entries) {
String headerName = entry.getKey();
if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) { if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) {
Object value = headers.get(headerName); Object value = entry.getValue();
if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) { if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) {
try { try {
String propertyName = this.fromHeaderName(headerName); String propertyName = this.fromHeaderName(headerName);

View File

@ -180,9 +180,9 @@ public class DefaultContextCache implements ContextCache {
} }
// Remove empty entries from the hierarchy map. // Remove empty entries from the hierarchy map.
for (MergedContextConfiguration currentKey : this.hierarchyMap.keySet()) { for (Map.Entry<MergedContextConfiguration, Set<MergedContextConfiguration>> entry : this.hierarchyMap.entrySet()) {
if (this.hierarchyMap.get(currentKey).isEmpty()) { if (entry.getValue().isEmpty()) {
this.hierarchyMap.remove(currentKey); this.hierarchyMap.remove(entry.getKey());
} }
} }
} }

View File

@ -113,8 +113,7 @@ class SessionAttributesHandler {
* @param attributes candidate attributes for session storage * @param attributes candidate attributes for session storage
*/ */
public void storeAttributes(WebSession session, Map<String, ?> attributes) { public void storeAttributes(WebSession session, Map<String, ?> attributes) {
attributes.keySet().forEach(name -> { attributes.forEach((name, value) -> {
Object value = attributes.get(name);
if (value != null && isHandlerSessionAttribute(name, value.getClass())) { if (value != null && isHandlerSessionAttribute(name, value.getClass())) {
session.getAttributes().put(name, value); session.getAttributes().put(name, value);
} }