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);
}
}
Set<String> headerNames = headers.keySet();
for (String headerName : headerNames) {
Set<Map.Entry<String, Object>> entries = headers.entrySet();
for (Map.Entry<String, Object> entry : entries) {
String headerName = entry.getKey();
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())) {
try {
String propertyName = this.fromHeaderName(headerName);

View File

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

View File

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