Author: remy.maucherat(a)jboss.com
Date: 2015-08-26 03:34:36 -0400 (Wed, 26 Aug 2015)
New Revision: 2621
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/connector/Request.java
Log:
BZ1246939: Fix issue uploading multiple files (with identical names).
Modified: branches/7.5.x/src/main/java/org/apache/catalina/connector/Request.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/catalina/connector/Request.java 2015-07-24
12:21:37 UTC (rev 2620)
+++ branches/7.5.x/src/main/java/org/apache/catalina/connector/Request.java 2015-08-26
07:34:36 UTC (rev 2621)
@@ -380,7 +380,7 @@
/**
* Parts associated with the request.
*/
- protected Map<String, Part> parts = null;
+ protected Collection<Part> parts = null;
/**
@@ -2936,7 +2936,7 @@
protected void parseMultipart()
throws IOException, ServletException {
- parts = Collections.emptyMap();
+ parts = Collections.emptyList();
if (context == null)
return;
@@ -2987,14 +2987,14 @@
upload.setFileSizeMax(config.getMaxFileSize());
upload.setSizeMax(config.getMaxRequestSize());
- parts = new HashMap<String, Part>();
+ parts = new ArrayList<Part>();
try {
for (FileItem fileItem : upload.parseRequest(getRequest())) {
if (fileItem.getName() == null) {
coyoteRequest.getParameters().addParameterValues
(fileItem.getFieldName(), new String[] {fileItem.getString()});
}
- parts.put(fileItem.getFieldName(), new StandardPart(fileItem, config));
+ parts.add(new StandardPart(fileItem, config));
}
} catch(FileSizeLimitExceededException e) {
throw MESSAGES.multipartProcessingFailed(e);
@@ -3300,7 +3300,15 @@
if (parts == null) {
parseMultipart();
}
- return parts.get(name);
+ Collection<Part> c = getParts();
+ Iterator<Part> iterator = c.iterator();
+ while (iterator.hasNext()) {
+ Part part = iterator.next();
+ if (name.equals(part.getName())) {
+ return part;
+ }
+ }
+ return null;
}
@@ -3308,7 +3316,7 @@
if (parts == null) {
parseMultipart();
}
- return parts.values();
+ return parts;
}
Show replies by date