avoid ConcurrentModificationException when iterating attribute names (SPR-7557)

This commit is contained in:
Juergen Hoeller 2010-10-01 22:27:34 +00:00
parent cbab6fa59f
commit aac2de9221
7 changed files with 23 additions and 18 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,6 +34,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletInputStream;
@ -284,7 +285,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
public Enumeration<String> getAttributeNames() {
checkActive();
return Collections.enumeration(this.attributes.keySet());
return new Vector<String>(this.attributes.keySet()).elements();
}
public String getCharacterEncoding() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,12 +17,12 @@
package org.springframework.mock.web;
import java.io.Serializable;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Vector;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
@ -137,7 +137,7 @@ public class MockHttpSession implements HttpSession {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return new Vector<String>(this.attributes.keySet()).elements();
}
public String[] getValueNames() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,10 +17,10 @@
package org.springframework.mock.web;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Vector;
import javax.el.ELContext;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@ -247,7 +247,7 @@ public class MockPageContext extends PageContext {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return new Vector<String>(this.attributes.keySet()).elements();
}
@SuppressWarnings("unchecked")

View File

@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.activation.FileTypeMap;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
@ -323,7 +324,7 @@ public class MockServletContext implements ServletContext {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return new Vector<String>(this.attributes.keySet()).elements();
}
public void setAttribute(String name, Object value) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,9 +28,10 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.activation.FileTypeMap;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequestDispatcher;
import javax.activation.FileTypeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -209,7 +210,7 @@ public class MockPortletContext implements PortletContext {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return new Vector<String>(this.attributes.keySet()).elements();
}
public void setAttribute(String name, Object value) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,6 +26,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.portlet.PortalContext;
import javax.portlet.PortletContext;
import javax.portlet.PortletMode;
@ -327,7 +328,7 @@ public class MockPortletRequest implements PortletRequest {
public Enumeration<String> getAttributeNames() {
checkActive();
return Collections.enumeration(this.attributes.keySet());
return new Vector<String>(this.attributes.keySet()).elements();
}
public void setParameters(Map<String, String[]> parameters) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import javax.portlet.PortletContext;
import javax.portlet.PortletSession;
import javax.servlet.http.HttpSessionBindingEvent;
@ -91,15 +92,15 @@ public class MockPortletSession implements PortletSession {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.portletAttributes.keySet());
return new Vector<String>(this.portletAttributes.keySet()).elements();
}
public Enumeration<String> getAttributeNames(int scope) {
if (scope == PortletSession.PORTLET_SCOPE) {
return Collections.enumeration(this.portletAttributes.keySet());
return new Vector<String>(this.portletAttributes.keySet()).elements();
}
else if (scope == PortletSession.APPLICATION_SCOPE) {
return Collections.enumeration(this.applicationAttributes.keySet());
return new Vector<String>(this.applicationAttributes.keySet()).elements();
}
return null;
}