[maven-release-plugin] copy for tag commons-fileupload-1.3.2
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/tags/commons-fileupload-1.3.2@1745306 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 34d8904..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,97 +0,0 @@
-<!---
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!---
- +======================================================================+
- |**** ****|
- |**** THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN ****|
- |**** DO NOT EDIT DIRECTLY ****|
- |**** ****|
- +======================================================================+
- | TEMPLATE FILE: contributing-md-template.md |
- | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
- +======================================================================+
- | |
- | 1) Re-generate using: mvn commons:contributing-md |
- | |
- | 2) Set the following properties in the component's pom: |
- | - commons.jira.id (required, alphabetic, upper case) |
- | |
- | 3) Example Properties |
- | |
- | <properties> |
- | <commons.jira.id>MATH</commons.jira.id> |
- | </properties> |
- | |
- +======================================================================+
---->
-Contributing to Apache Commons FileUpload
-======================
-
-You have found a bug or you have an idea for a cool new feature? Contributing code is a great way to give something back to
-the open source community. Before you dig right into the code there are a few guidelines that we need contributors to
-follow so that we can have a chance of keeping on top of things.
-
-Getting Started
----------------
-
-+ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
-+ Make sure you have a [GitHub account](https://github.com/signup/free).
-+ If you're planning to implement a new feature it makes sense to discuss you're changes on the [dev list](https://commons.apache.org/mail-lists.html) first. This way you can make sure you're not wasting your time on something that isn't considered to be in Apache Commons FileUpload's scope.
-+ Submit a ticket for your issue, assuming one does not already exist.
- + Clearly describe the issue including steps to reproduce when it is a bug.
- + Make sure you fill in the earliest version that you know has the issue.
-+ Fork the repository on GitHub.
-
-Making Changes
---------------
-
-+ Create a topic branch from where you want to base your work (this is usually the master/trunk branch).
-+ Make commits of logical units.
-+ Respect the original code style:
- + Only use spaces for indentation.
- + Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
- + Check for unnecessary whitespace with git diff --check before committing.
-+ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue.
-+ Make sure you have added the necessary tests for your changes.
-+ Run all the tests with `mvn clean verify` to assure nothing else was accidentally broken.
-
-Making Trivial Changes
-----------------------
-
-For changes of a trivial nature to comments and documentation, it is not always necessary to create a new ticket in JIRA.
-In this case, it is appropriate to start the first line of a commit with '(doc)' instead of a ticket number.
-
-Submitting Changes
-------------------
-
-+ Sign the [Contributor License Agreement][cla] if you haven't already.
-+ Push your changes to a topic branch in your fork of the repository.
-+ Submit a pull request to the repository in the apache organization.
-+ Update your JIRA ticket and include a link to the pull request in the ticket.
-
-Additional Resources
---------------------
-
-+ [Contributing patches](https://commons.apache.org/patches.html)
-+ [Apache Commons FileUpload JIRA project page](https://issues.apache.org/jira/browse/FILEUPLOAD)
-+ [Contributor License Agreement][cla]
-+ [General GitHub documentation](https://help.github.com/)
-+ [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
-+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
-+ #apachecommons IRC channel on freenode.org
-
-[cla]:https://www.apache.org/licenses/#clas
diff --git a/README.md b/README.md
deleted file mode 100644
index cb76d89..0000000
--- a/README.md
+++ /dev/null
@@ -1,99 +0,0 @@
-<!---
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!---
- +======================================================================+
- |**** ****|
- |**** THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN ****|
- |**** DO NOT EDIT DIRECTLY ****|
- |**** ****|
- +======================================================================+
- | TEMPLATE FILE: readme-md-template.md |
- | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
- +======================================================================+
- | |
- | 1) Re-generate using: mvn commons:readme-md |
- | |
- | 2) Set the following properties in the component's pom: |
- | - commons.componentid (required, alphabetic, lower case) |
- | - commons.release.version (required) |
- | |
- | 3) Example Properties |
- | |
- | <properties> |
- | <commons.componentid>math</commons.componentid> |
- | <commons.release.version>1.2</commons.release.version> |
- | </properties> |
- | |
- +======================================================================+
---->
-Apache Commons FileUpload
-===================
-
-The Apache Commons FileUpload component provides a simple yet flexible means of adding support for multipart
- file upload functionality to servlets and web applications.
-
-Documentation
--------------
-
-More information can be found on the [homepage](https://commons.apache.org/proper/commons-fileupload).
-The [JavaDoc](https://commons.apache.org/proper/commons-fileupload/apidocs) can be browsed.
-Questions related to the usage of Apache Commons FileUpload should be posted to the [user mailing list][ml].
-
-Where can I get the latest release?
------------------------------------
-You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-fileupload/download_fileupload.cgi).
-
-Alternatively you can pull it from the central Maven repositories:
-
-```xml
-<dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.3.1</version>
-</dependency>
-```
-
-Contributing
-------------
-
-We accept PRs via github. The [developer mailing list][ml] is the main channel of communication for contributors.
-There are some guidelines which will make applying PRs easier for us:
-+ No tabs! Please use spaces for indentation.
-+ Respect the code style.
-+ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
-+ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn clean test```.
-
-If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas).
-You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md).
-
-License
--------
-Code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0.txt).
-
-Donations
----------
-You like Apache Commons FileUpload? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development.
-
-Additional Resources
---------------------
-
-+ [Apache Commons Homepage](https://commons.apache.org/)
-+ [Apache Bugtracker (JIRA)](https://issues.apache.org/jira/)
-+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
-+ #apachecommons IRC channel on freenode.org
-
-[ml]:https://commons.apache.org/mail-lists.html
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 2c34603..bc33acb 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,3 +1,25 @@
+ Apache Commons FileUpload 1.3.2 RELEASE NOTES
+
+The Apache Commons FileUpload team is pleased to announce the release of Apache Commons FileUpload 1.3.2.
+
+The Apache Commons FileUpload component provides a simple yet flexible means of
+adding support for multipart file upload functionality to servlets and web
+applications. Version 1.3 onwards requires Java 5 or later.
+
+No client code changes are required to migrate from version 1.3.1 to 1.3.2.
+
+Changes in version 1.3.2 include:
+
+o FILEUPLOAD-272: Performance Improvement in MultipartStream
+
+
+For complete information on Apache Commons FileUpload, including instructions on how to submit bug reports,
+patches, or suggestions for improvement, see the Apache Apache Commons FileUpload website:
+
+http://commons.apache.org/proper/commons-fileupload/
+
+------------------------------------------------------------------------------
+
Apache Commons FileUpload 1.3.1 RELEASE NOTES
The Apache Commons FileUpload team is pleased to announce the release of Apache Commons FileUpload 1.3.1.
@@ -31,3 +53,4 @@
patches, or suggestions for improvement, see the Apache Apache Commons FileUpload website:
http://commons.apache.org/proper/commons-fileupload/
+
diff --git a/build.properties b/build.properties
index 185a280..6325561 100644
--- a/build.properties
+++ b/build.properties
@@ -47,7 +47,7 @@
sonar.host.url=https\://analysis.apache.org/
commons.rc.version=RC1
commons.cobertura.version=2.5.2
-commons.release.name=commons-fileupload-1.4
+commons.release.name=commons-fileupload-1.3
minSeverity=info
maven.build.testOutputDir=${maven.build.dir}/test-classes
project.reporting.outputEncoding=iso-8859-1
diff --git a/doap_fileupload.rdf b/doap_fileupload.rdf
new file mode 100644
index 0000000..29fd6e3
--- /dev/null
+++ b/doap_fileupload.rdf
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:asfext="http://projects.apache.org/ns/asfext#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:doap="http://usefulinc.com/ns/doap#" xml:lang="en">
+ <Project rdf:about="http://commons.apache.org/fileupload/">
+ <name>Apache Commons FileUpload</name>
+ <homepage rdf:resource="http://commons.apache.org/fileupload/"/>
+ <programming-language>Java</programming-language>
+ <category rdf:resource="http://projects.apache.org/category/library"/>
+ <license rdf:resource="http://usefulinc.com/doap/licenses/asl20"/>
+ <bug-database rdf:resource="http://issues.apache.org/jira/browse/FILEUPLOAD"/>
+ <download-page rdf:resource="http://commons.apache.org/fileupload/download_fileupload.cgi"/>
+ <asfext:pmc rdf:resource="http://commons.apache.org/"/>
+ <shortdesc xml:lang="en">File upload component for Java servlets</shortdesc>
+ <description xml:lang="en">
+ The FileUpload component provides a simple yet flexible means of adding
+ support for multipart file upload functionality to servlets and web
+ applications.
+ </description>
+ <repository>
+ <SVNRepository>
+ <browse rdf:resource="http://svn.apache.org/repos/asf"/>
+ <location rdf:resource="http://svn.apache.org/repos/asf/commons/proper/fileupload"/>
+ </SVNRepository>
+ </repository>
+ <release>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2013-03-27</created>
+ <revision>1.3</revision>
+ </Version>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2010-07-29</created>
+ <revision>1.2.2</revision>
+ </Version>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2008-01-18</created>
+ <revision>1.2.1</revision>
+ </Version>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2007-02-13</created>
+ <revision>1.2</revision>
+ </Version>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2006-06-08</created>
+ <revision>1.1.1</revision>
+ </Version>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2005-12-23</created>
+ <revision>1.1</revision>
+ </Version>
+ <Version>
+ <name>commons-fileupload</name>
+ <created>2003-06-24</created>
+ <revision>1.0</revision>
+ </Version>
+ </release>
+ <mailing-list rdf:resource="http://commons.apache.org/mail-lists.html"/>
+ </Project>
+</rdf:RDF>
diff --git a/pom.xml b/pom.xml
index 6baa153..b90e789 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>1.3.2</version>
<name>Apache Commons FileUpload</name>
<description>
@@ -167,9 +167,9 @@
</contributors>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/commons/proper/fileupload/trunk</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk</developerConnection>
- <url>http://svn.apache.org/viewvc/commons/proper/fileupload/trunk</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/commons/proper/fileupload/tags/commons-fileupload-1.3.2</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/proper/fileupload/tags/commons-fileupload-1.3.2</developerConnection>
+ <url>http://svn.apache.org/viewvc/commons/proper/fileupload/tags/commons-fileupload-1.3.2</url>
</scm>
<issueManagement>
<system>jira</system>
@@ -179,9 +179,9 @@
<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
+ <maven.compile.encoding>ISO-8859-1</maven.compile.encoding>
<commons.componentid>fileupload</commons.componentid>
- <commons.release.version>1.4</commons.release.version>
- <commons.release.desc>(requires Java ${maven.compiler.target} or later)</commons.release.desc>
+ <commons.release.version>1.3.2</commons.release.version>
<commons.rc.version>RC1</commons.rc.version>
<commons.jira.id>FILEUPLOAD</commons.jira.id>
<commons.jira.pid>12310476</commons.jira.pid>
@@ -236,6 +236,46 @@
</configuration>
</plugin>
</plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.apache.org/repos/asf/commons/proper/fileupload/tags</tagBase>
+ </configuration>
+ </plugin>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.apache.maven.plugins
+ </groupId>
+ <artifactId>
+ maven-antrun-plugin
+ </artifactId>
+ <versionRange>[1.7,)</versionRange>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<reporting>
@@ -264,7 +304,6 @@
<configLocation>${basedir}/src/checkstyle/fileupload_checks.xml</configLocation>
<suppressionsLocation>${basedir}/src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<enableRulesSummary>false</enableRulesSummary>
- <headerLocation>${basedir}/src/checkstyle/license-header.txt</headerLocation>
</configuration>
</plugin>
<plugin>
@@ -283,16 +322,9 @@
<artifactId>clirr-maven-plugin</artifactId>
<version>${commons.clirr.version}</version>
<configuration>
- <comparisonArtifacts>
- <comparisonArtifact>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.3</version>
- </comparisonArtifact>
- </comparisonArtifacts>
+ <comparisonVersion>1.3</comparisonVersion>
</configuration>
</plugin>
</plugins>
</reporting>
-
</project>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fdcf43e..bc1b921 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,20 +43,10 @@
</properties>
<body>
- <release version="1.4" date="TBA" description="TBA">
- <action issue="FILEUPLOAD-252" dev="tn" type="fix">DiskFileItem#write() could lose original IO exception</action>
- <action issue="FILEUPLOAD-258" dev="tn" type="fix">DiskFileItem#getStoreLocation() wrongly returned a File object for items stored in memory</action>
- <action issue="FILEUPLOAD-242" dev="tn" type="fix">FileUploadBase - should not silently catch and ignore all Throwables</action>
- <action issue="FILEUPLOAD-257" dev="tn" type="fix">Fix Javadoc 1.8.0 errors</action>
- <action issue="FILEUPLOAD-234" dev="tn" type="fix">Fix section "Resource cleanup" of the user guide</action>
- <action issue="FILEUPLOAD-237" dev="tn" type="fix">Fix streaming example: use FileItem.getInputStream() instead of openStream()</action>
- <action issue="FILEUPLOAD-248" dev="ecki" type="fix">DiskFileItem might suppress critical IOExceptions on rename - use FileUtil.move instead</action>
- <action issue="FILEUPLOAD-251" dev="sebb" type="fix">DiskFileItem#getTempFile() is broken</action>
- <action issue="FILEUPLOAD-250" dev="sebb" type="fix">FileUploadBase - potential resource leak - InputStream not closed on exception</action>
- <action issue="FILEUPLOAD-244" dev="sebb" type="fix">DiskFileItem.readObject fails to close FileInputStream</action>
- <action issue="FILEUPLOAD-246" dev="sebb" type="update">FileUpload should use IOUtils.closeQuietly where relevant</action>
- <action issue="FILEUPLOAD-245" dev="sebb" type="fix">DiskFileItem.get() may not fully read the data</action>
- <action issue="FILEUPLOAD-243" dev="sebb" type="update" due-to="Ville Skyttä">Make some MultipartStream private fields final</action>
+ <release version="1.3.2" description="Bugfix release for 1.3.1" date="tba">
+ <action issue="FILEUPLOAD-272" dev="jochen" type="update">
+ Performance Improvement in MultipartStream
+ </action>
</release>
<release version="1.3.1" description=
diff --git a/src/checkstyle/fileupload_checks.xml b/src/checkstyle/fileupload_checks.xml
index b49a4f4..77699c3 100644
--- a/src/checkstyle/fileupload_checks.xml
+++ b/src/checkstyle/fileupload_checks.xml
@@ -74,12 +74,6 @@
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
- <!-- Following interprets the header file as regular expressions. -->
- <!-- <module name="RegexpHeader"/> -->
- <module name="RegexpHeader">
- <property name="headerFile" value="${checkstyle.header.file}"/>
- </module>
-
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>
diff --git a/src/checkstyle/license-header.txt b/src/checkstyle/license-header.txt
deleted file mode 100644
index 290c957..0000000
--- a/src/checkstyle/license-header.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-/\*\s*
- \*\s*Licensed to the Apache Software Foundation \(ASF\) under one or more
- \*\s*contributor license agreements. See the NOTICE file distributed with
- \*\s*this work for additional information regarding copyright ownership\.
- \*\s*The ASF licenses this file to You under the Apache License, Version 2\.0
- \*\s*\(the "License"\); you may not use this file except in compliance with
- \*\s*the License\. You may obtain a copy of the License at
- \*\s*
- \*\s*http://www\.apache\.org/licenses/LICENSE\-2\.0
- \*\s*
- \*\s*Unless required by applicable law or agreed to in writing, software
- \*\s*distributed under the License is distributed on an "AS IS" BASIS,
- \*\s*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
- \*\s*See the License for the specific language governing permissions and
- \*\s*limitations under the License\.
- \*/\s*
diff --git a/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java b/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java
index 58c9c7f..6fecb37 100644
--- a/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java
+++ b/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java
@@ -28,7 +28,7 @@
* disk, is configurable, as is the directory in which temporary files will be
* created.</p>
*
- * <p>If not otherwise configured, the default configuration values are as
+ * If not otherwise configured, the default configuration values are as
* follows:
* <ul>
* <li>Size threshold is 10KB.</li>
diff --git a/src/main/java/org/apache/commons/fileupload/FileItem.java b/src/main/java/org/apache/commons/fileupload/FileItem.java
index 99203b3..484719f 100644
--- a/src/main/java/org/apache/commons/fileupload/FileItem.java
+++ b/src/main/java/org/apache/commons/fileupload/FileItem.java
@@ -46,7 +46,7 @@
* @version $Id$
* @since 1.3 additionally implements FileItemHeadersSupport
*/
-public interface FileItem extends FileItemHeadersSupport {
+public interface FileItem extends Serializable, FileItemHeadersSupport {
// ------------------------------- Methods from javax.activation.DataSource
diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
index 1795b3d..b567bd9 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
@@ -38,7 +38,6 @@
import org.apache.commons.fileupload.util.FileItemHeadersImpl;
import org.apache.commons.fileupload.util.LimitedInputStream;
import org.apache.commons.fileupload.util.Streams;
-import org.apache.commons.io.IOUtils;
/**
* <p>High level API for processing file uploads.</p>
@@ -366,8 +365,8 @@
for (FileItem fileItem : items) {
try {
fileItem.delete();
- } catch (Exception ignored) {
- // ignored TODO perhaps add to tracker delete failure list somehow?
+ } catch (Throwable e) {
+ // ignore it
}
}
}
@@ -950,6 +949,7 @@
MULTIPART_FORM_DATA, MULTIPART_MIXED, contentType));
}
+ InputStream input = ctx.getInputStream();
@SuppressWarnings("deprecation") // still has to be backward compatible
final int contentLengthInt = ctx.getContentLength();
@@ -960,7 +960,6 @@
: contentLengthInt;
// CHECKSTYLE:ON
- InputStream input; // N.B. this is eventually closed in MultipartStream processing
if (sizeMax >= 0) {
if (requestSize != -1 && requestSize > sizeMax) {
throw new SizeLimitExceededException(
@@ -968,8 +967,7 @@
Long.valueOf(requestSize), Long.valueOf(sizeMax)),
requestSize, sizeMax);
}
- // N.B. this is eventually closed in MultipartStream processing
- input = new LimitedInputStream(ctx.getInputStream(), sizeMax) {
+ input = new LimitedInputStream(input, sizeMax) {
@Override
protected void raiseError(long pSizeMax, long pCount)
throws IOException {
@@ -980,8 +978,6 @@
throw new FileUploadIOException(ex);
}
};
- } else {
- input = ctx.getInputStream();
}
String charEncoding = headerEncoding;
@@ -991,7 +987,6 @@
boundary = getBoundary(contentType);
if (boundary == null) {
- IOUtils.closeQuietly(input); // avoid possible resource leak
throw new FileUploadException("the request was rejected because no multipart boundary was found");
}
@@ -999,7 +994,6 @@
try {
multi = new MultipartStream(input, boundary, notifier);
} catch (IllegalArgumentException iae) {
- IOUtils.closeQuietly(input); // avoid possible resource leak
throw new InvalidContentTypeException(
format("The boundary specified in the %s header is too long", CONTENT_TYPE), iae);
}
@@ -1367,7 +1361,7 @@
/**
* @deprecated 1.2 Replaced by
- * {@link #SizeLimitExceededException(String, long, long)}
+ * {@code SizeLimitExceededException(String, long, long)}
*/
@Deprecated
public SizeLimitExceededException() {
@@ -1376,7 +1370,7 @@
/**
* @deprecated 1.2 Replaced by
- * {@link #SizeLimitExceededException(String, long, long)}
+ * {@code #SizeLimitExceededException(String, long, long)}
* @param message The exceptions detail message.
*/
@Deprecated
diff --git a/src/main/java/org/apache/commons/fileupload/MultipartStream.java b/src/main/java/org/apache/commons/fileupload/MultipartStream.java
index 0d05b71..045dac3 100644
--- a/src/main/java/org/apache/commons/fileupload/MultipartStream.java
+++ b/src/main/java/org/apache/commons/fileupload/MultipartStream.java
@@ -222,12 +222,12 @@
* The amount of data, in bytes, that must be kept in the buffer in order
* to detect delimiters reliably.
*/
- private final int keepRegion;
+ private int keepRegion;
/**
* The byte sequence that partitions the stream.
*/
- private final byte[] boundary;
+ private byte[] boundary;
/**
* The length of the buffer used for processing the request.
@@ -334,7 +334,7 @@
}
this.input = input;
- this.bufSize = Math.max(bufSize, boundaryLength*2);
+ this.bufSize = Math.max(bufSize, boundaryLength * 2);
this.buffer = new byte[this.bufSize];
this.notifier = pNotifier;
@@ -589,7 +589,8 @@
*/
public int readBodyData(OutputStream output)
throws MalformedStreamException, IOException {
- return (int) Streams.copy(newInputStream(), output, false); // N.B. Streams.copy closes the input stream
+ final InputStream istream = newInputStream();
+ return (int) Streams.copy(istream, output, false);
}
/**
diff --git a/src/main/java/org/apache/commons/fileupload/ParameterParser.java b/src/main/java/org/apache/commons/fileupload/ParameterParser.java
index 30676e8..3db521a 100644
--- a/src/main/java/org/apache/commons/fileupload/ParameterParser.java
+++ b/src/main/java/org/apache/commons/fileupload/ParameterParser.java
@@ -78,8 +78,8 @@
/**
* Are there any characters left to parse?
*
- * @return {@code true} if there are unparsed characters,
- * {@code false} otherwise.
+ * @return <tt>true</tt> if there are unparsed characters,
+ * <tt>false</tt> otherwise.
*/
private boolean hasChar() {
return this.pos < this.len;
@@ -90,8 +90,8 @@
* leading and trailing blanks as well as enclosing quotation marks,
* when necessary.
*
- * @param quoted {@code true} if quotation marks are expected,
- * {@code false} otherwise.
+ * @param quoted <tt>true</tt> if quotation marks are expected,
+ * <tt>false</tt> otherwise.
* @return the token
*/
private String getToken(boolean quoted) {
@@ -124,8 +124,8 @@
* @param ch the character to test for presense in the array of characters
* @param charray the array of characters to test against
*
- * @return {@code true} if the character is present in the array of
- * characters, {@code false} otherwise.
+ * @return <tt>true</tt> if the character is present in the array of
+ * characters, <tt>false</tt> otherwise.
*/
private boolean isOneOf(char ch, final char[] charray) {
boolean result = false;
@@ -195,12 +195,12 @@
}
/**
- * Returns {@code true} if parameter names are to be converted to lower
+ * Returns <tt>true</tt> if parameter names are to be converted to lower
* case when name/value pairs are parsed.
*
- * @return {@code true} if parameter names are to be
+ * @return <tt>true</tt> if parameter names are to be
* converted to lower case when name/value pairs are parsed.
- * Otherwise returns {@code false}
+ * Otherwise returns <tt>false</tt>
*/
public boolean isLowerCaseNames() {
return this.lowerCaseNames;
@@ -210,9 +210,9 @@
* Sets the flag if parameter names are to be converted to lower case when
* name/value pairs are parsed.
*
- * @param b {@code true} if parameter names are to be
+ * @param b <tt>true</tt> if parameter names are to be
* converted to lower case when name/value pairs are parsed.
- * {@code false} otherwise.
+ * <tt>false</tt> otherwise.
*/
public void setLowerCaseNames(boolean b) {
this.lowerCaseNames = b;
diff --git a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
index 3cc45a0..779e47b 100644
--- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
+++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
@@ -16,8 +16,10 @@
*/
package org.apache.commons.fileupload.disk;
-import static java.lang.String.*;
+import static java.lang.String.format;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -37,7 +39,6 @@
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.ParameterParser;
import org.apache.commons.fileupload.util.Streams;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.DeferredFileOutputStream;
@@ -296,12 +297,11 @@
* contents of the file were not yet cached in memory, they will be
* loaded from the disk storage and cached.
*
- * @return The contents of the file as an array of bytes
- * or {@code null} if the data cannot be read
+ * @return The contents of the file as an array of bytes.
*/
public byte[] get() {
if (isInMemory()) {
- if (cachedContent == null && dfos != null) {
+ if (cachedContent == null) {
cachedContent = dfos.getData();
}
return cachedContent;
@@ -311,12 +311,18 @@
InputStream fis = null;
try {
- fis = new FileInputStream(dfos.getFile());
- IOUtils.readFully(fis, fileData);
+ fis = new BufferedInputStream(new FileInputStream(dfos.getFile()));
+ fis.read(fileData);
} catch (IOException e) {
fileData = null;
} finally {
- IOUtils.closeQuietly(fis);
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
return fileData;
@@ -387,9 +393,10 @@
try {
fout = new FileOutputStream(file);
fout.write(get());
- fout.close();
} finally {
- IOUtils.closeQuietly(fout);
+ if (fout != null) {
+ fout.close();
+ }
}
} else {
File outputFile = getStoreLocation();
@@ -401,7 +408,32 @@
* in a temporary location so move it to the
* desired file.
*/
- FileUtils.moveFile(outputFile, file);
+ if (!outputFile.renameTo(file)) {
+ BufferedInputStream in = null;
+ BufferedOutputStream out = null;
+ try {
+ in = new BufferedInputStream(
+ new FileInputStream(outputFile));
+ out = new BufferedOutputStream(
+ new FileOutputStream(file));
+ IOUtils.copy(in, out);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
} else {
/*
* For whatever reason we cannot write the
@@ -486,7 +518,7 @@
* be used for storing the contents of the file.
*
* @return An {@link java.io.OutputStream OutputStream} that can be used
- * for storing the contents of the file.
+ * for storing the contensts of the file.
*
* @throws IOException if an error occurs.
*/
@@ -518,9 +550,6 @@
if (dfos == null) {
return null;
}
- if (isInMemory()) {
- return null;
- }
return dfos.getFile();
}
@@ -531,9 +560,6 @@
*/
@Override
protected void finalize() {
- if (dfos == null) {
- return;
- }
File outputFile = dfos.getFile();
if (outputFile != null && outputFile.exists()) {
@@ -546,9 +572,6 @@
* named temporary file in the configured repository path. The lifetime of
* the file is tied to the lifetime of the <code>FileItem</code> instance;
* the file will be deleted when the instance is garbage collected.
- * <p>
- * <b>Note: Subclasses that override this method must ensure that they return the
- * same File each time.</b>
*
* @return The {@link java.io.File File} to be used for temporary storage.
*/
@@ -570,7 +593,7 @@
/**
* Returns an identifier that is unique within the class loader used to
- * load this class, but does not have random-like appearance.
+ * load this class, but does not have random-like apearance.
*
* @return A String with the non-random looking instance identifier.
*/
@@ -599,6 +622,75 @@
Boolean.valueOf(isFormField()), getFieldName());
}
+ // -------------------------------------------------- Serialization methods
+
+ /**
+ * Writes the state of this object during serialization.
+ *
+ * @param out The stream to which the state should be written.
+ *
+ * @throws IOException if an error occurs.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ // Read the data
+ if (dfos.isInMemory()) {
+ cachedContent = get();
+ } else {
+ cachedContent = null;
+ dfosFile = dfos.getFile();
+ }
+
+ // write out values
+ out.defaultWriteObject();
+ }
+
+ /**
+ * Reads the state of this object during deserialization.
+ *
+ * @param in The stream from which the state should be read.
+ *
+ * @throws IOException if an error occurs.
+ * @throws ClassNotFoundException if class cannot be found.
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ // read values
+ in.defaultReadObject();
+
+ /* One expected use of serialization is to migrate HTTP sessions
+ * containing a DiskFileItem between JVMs. Particularly if the JVMs are
+ * on different machines It is possible that the repository location is
+ * not valid so validate it.
+ */
+ if (repository != null) {
+ if (repository.isDirectory()) {
+ // Check path for nulls
+ if (repository.getPath().contains("\0")) {
+ throw new IOException(format(
+ "The repository [%s] contains a null character",
+ repository.getPath()));
+ }
+ } else {
+ throw new IOException(format(
+ "The repository [%s] is not a directory",
+ repository.getAbsolutePath()));
+ }
+ }
+
+ OutputStream output = getOutputStream();
+ if (cachedContent != null) {
+ output.write(cachedContent);
+ } else {
+ FileInputStream input = new FileInputStream(dfosFile);
+ IOUtils.copy(input, output);
+ dfosFile.delete();
+ dfosFile = null;
+ }
+ output.close();
+
+ cachedContent = null;
+ }
+
/**
* Returns the file item headers.
* @return The file items headers.
diff --git a/src/site/resources/download_fileupload.cgi b/src/site/resources/download_fileupload.cgi
old mode 100755
new mode 100644
diff --git a/src/site/xdoc/download_fileupload.xml b/src/site/xdoc/download_fileupload.xml
index 90bdaf8..ae4a5e6 100644
--- a/src/site/xdoc/download_fileupload.xml
+++ b/src/site/xdoc/download_fileupload.xml
@@ -31,10 +31,21 @@
| 2) Set the following properties in the component's pom: |
| - commons.componentid (required, alphabetic, lower case) |
| - commons.release.version (required) |
- | - commons.binary.suffix (optional) |
+ | - commons.release.name (required) |
+ | - commons.binary.suffix (optional) |
| (defaults to "-bin", set to "" for pre-maven2 releases) |
+ | - commons.release.desc (optional) |
+ | - commons.release.subdir (optional) |
+ | |
+ | - commons.release.2/3.version (conditional) |
+ | - commons.release.2/3.name (conditional) |
+ | - commons.release.2/3.binary.suffix (optional) |
+ | - commons.release.2/3.desc (optional) |
+ | - commons.release.2/3.subdir (optional) |
| |
| 3) Example Properties |
+ | (commons.release.name inherited by parent: |
+ | ${project.artifactId}-${commons.release.version} |
| |
| <properties> |
| <commons.componentid>math</commons.componentid> |
@@ -46,17 +57,17 @@
<document>
<properties>
<title>Download Apache Commons FileUpload</title>
- <author email="dev@commons.apache.org">Commons Documentation Team</author>
+ <author email="dev@commons.apache.org">Apache Commons Documentation Team</author>
</properties>
<body>
<section name="Download Apache Commons FileUpload">
<subsection name="Using a Mirror">
<p>
We recommend you use a mirror to download our release
- builds, but you <strong>must</strong> verify the integrity of
+ builds, but you <strong>must</strong> <a href="http://www.apache.org/info/verification.html">verify the integrity</a> of
the downloaded files using signatures downloaded from our main
distribution directories. Recent releases (48 hours) may not yet
- be available from the mirrors.
+ be available from all the mirrors.
</p>
<p>
@@ -88,39 +99,44 @@
</form>
<p>
- The <a href="http://www.apache.org/dist/commons/KEYS">KEYS</a>
- link links to the code signing keys used to sign the product.
- The <code>PGP</code> link downloads the OpenPGP compatible signature from our main site.
- The <code>MD5</code> link downloads the checksum from the main site.
+ It is essential that you
+ <a href="https://www.apache.org/info/verification.html">verify the integrity</a>
+ of downloaded files, preferably using the <code>PGP</code> signature (<code>*.asc</code> files);
+ failing that using the <code>MD5</code> hash (<code>*.md5</code> checksum files).
+ </p>
+ <p>
+ The <a href="https://www.apache.org/dist/commons/KEYS">KEYS</a>
+ file contains the public PGP keys used by Apache Commons developers
+ to sign releases.
</p>
</subsection>
</section>
- <section name="Apache Commons FileUpload 1.3.1 (requires Java 1.5 or later)">
+ <section name="Apache Commons FileUpload 1.3.2 ">
<subsection name="Binaries">
<table>
<tr>
- <td><a href="[preferred]/commons/fileupload/binaries/commons-fileupload-1.3.1-bin.tar.gz">commons-fileupload-1.3.1-bin.tar.gz</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.1-bin.tar.gz.md5">md5</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.1-bin.tar.gz.asc">pgp</a></td>
+ <td><a href="[preferred]/commons/fileupload/binaries/commons-fileupload-1.3.2-bin.tar.gz">commons-fileupload-1.3.2-bin.tar.gz</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.2-bin.tar.gz.md5">md5</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.2-bin.tar.gz.asc">pgp</a></td>
</tr>
<tr>
- <td><a href="[preferred]/commons/fileupload/binaries/commons-fileupload-1.3.1-bin.zip">commons-fileupload-1.3.1-bin.zip</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.1-bin.zip.md5">md5</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.1-bin.zip.asc">pgp</a></td>
+ <td><a href="[preferred]/commons/fileupload/binaries/commons-fileupload-1.3.2-bin.zip">commons-fileupload-1.3.2-bin.zip</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.2-bin.zip.md5">md5</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.3.2-bin.zip.asc">pgp</a></td>
</tr>
</table>
</subsection>
<subsection name="Source">
<table>
<tr>
- <td><a href="[preferred]/commons/fileupload/source/commons-fileupload-1.3.1-src.tar.gz">commons-fileupload-1.3.1-src.tar.gz</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.1-src.tar.gz.md5">md5</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.1-src.tar.gz.asc">pgp</a></td>
+ <td><a href="[preferred]/commons/fileupload/source/commons-fileupload-1.3.2-src.tar.gz">commons-fileupload-1.3.2-src.tar.gz</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.2-src.tar.gz.md5">md5</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.2-src.tar.gz.asc">pgp</a></td>
</tr>
<tr>
- <td><a href="[preferred]/commons/fileupload/source/commons-fileupload-1.3.1-src.zip">commons-fileupload-1.3.1-src.zip</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.1-src.zip.md5">md5</a></td>
- <td><a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.1-src.zip.asc">pgp</a></td>
+ <td><a href="[preferred]/commons/fileupload/source/commons-fileupload-1.3.2-src.zip">commons-fileupload-1.3.2-src.zip</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.2-src.zip.md5">md5</a></td>
+ <td><a href="https://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3.2-src.zip.asc">pgp</a></td>
</tr>
</table>
</subsection>
@@ -131,7 +147,7 @@
</p>
<ul>
<li class="download"><a href="[preferred]/commons/fileupload/">browse download area</a></li>
- <li><a href="http://archive.apache.org/dist/commons/fileupload/">archives...</a></li>
+ <li><a href="https://archive.apache.org/dist/commons/fileupload/">archives...</a></li>
</ul>
</section>
</body>
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index b4315de..1a99d22 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -67,22 +67,16 @@
<section name="Downloading">
<subsection name="Full Releases">
- <p><strong>FileUpload 1.3.1</strong> - 7 February 2014</p>
+ <p><strong>FileUpload 1.3</strong> - 27 March 2013</p>
<ul>
<li>Download the binary and source distributions from a mirror site
<a href="http://commons.apache.org/fileupload/download_fileupload.cgi">here</a>
</li>
</ul>
- <p><strong>FileUpload 1.3</strong> - 27 March 2013</p>
- <ul>
- <li>Download the binary and source distributions from the archive site
- <a href="http://archive.apache.org/dist/commons/fileupload/">here</a>
- </li>
- </ul>
<p><strong>FileUpload 1.2.2</strong> - 29 July 2010</p>
<ul>
- <li>Download the binary and source distributions from the archive site
- <a href="http://archive.apache.org/dist/commons/fileupload/">here</a>
+ <li>Download the binary and source distributions from a mirror site
+ <a href="http://commons.apache.org/fileupload/download_fileupload.cgi">here</a>
</li>
</ul>
<p><strong>FileUpload 1.2.1</strong> - 18 January 2008</p>
diff --git a/src/site/xdoc/streaming.xml b/src/site/xdoc/streaming.xml
index 5f2dd86..2c2cd10 100644
--- a/src/site/xdoc/streaming.xml
+++ b/src/site/xdoc/streaming.xml
@@ -68,7 +68,7 @@
while (iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
- InputStream stream = item.getInputStream();
+ InputStream stream = item.openStream();
if (item.isFormField()) {
System.out.println("Form field " + name + " with value "
+ Streams.asString(stream) + " detected.");
diff --git a/src/site/xdoc/using.xml b/src/site/xdoc/using.xml
index 410ea57..8e2113b 100644
--- a/src/site/xdoc/using.xml
+++ b/src/site/xdoc/using.xml
@@ -284,8 +284,8 @@
</p>
<p>
Such temporary files are deleted automatically, if they are no longer
- used (more precisely, if the corresponding instance of <code>DiskFileItem</code>
- is garbage collected. This is done silently by the <code>org.apache.commons.io.FileCleanerTracker</code>
+ used (more precisely, if the corresponding instance of <code>java.io.File</code>
+ is garbage collected. This is done silently by the <code>org.apache.commons.io.FileCleaner</code>
class, which starts a reaper thread.
</p>
<p>
diff --git a/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java b/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java
index e296d73..e823f74 100644
--- a/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java
+++ b/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java
@@ -31,10 +31,6 @@
import java.io.OutputStream;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
/**
@@ -45,27 +41,6 @@
*/
public class DiskFileItemSerializeTest {
- // Use a private repo to catch any files left over by tests
- private static final File REPO = new File(System.getProperty("java.io.tmpdir"), "diskfileitemrepo");
-
- @Before
- public void setUp() throws Exception {
- if (REPO.exists()) {
- FileUtils.deleteDirectory(REPO);
- }
- assertFalse("Must not exist", REPO.exists());
- REPO.mkdir();
- }
-
- @After
- public void tearDown() {
- for(File file : FileUtils.listFiles(REPO, null, true)) {
- System.out.println("Found leftover file " + file);
- }
- REPO.delete();
- assertFalse(REPO + " is not empty", REPO.exists());
- }
-
/**
* Content type for regular form items.
*/
@@ -102,7 +77,7 @@
* Helper method to test creation of a field.
*/
private void testInMemoryObject(byte[] testFieldValueBytes) {
- testInMemoryObject(testFieldValueBytes, REPO);
+ testInMemoryObject(testFieldValueBytes, null);
}
/**
@@ -150,10 +125,7 @@
compareBytes("Check", testFieldValueBytes, newItem.get());
// Compare FileItem's (except byte[])
- compareFileItems(item, newItem);
-
- item.delete();
- newItem.delete();
+ compareFileItems(item, newItem);
}
/**
@@ -163,7 +135,8 @@
public void testValidRepository() throws Exception {
// Create the FileItem
byte[] testFieldValueBytes = createContentBytes(threshold);
- testInMemoryObject(testFieldValueBytes, REPO);
+ File repository = new File(System.getProperty("java.io.tmpdir"));
+ testInMemoryObject(testFieldValueBytes, repository);
}
/**
@@ -173,7 +146,7 @@
public void testInvalidRepository() throws Exception {
// Create the FileItem
byte[] testFieldValueBytes = createContentBytes(threshold);
- File repository = new File(System.getProperty("java.io.tmpdir"), "file");
+ File repository = new File(System.getProperty("java.io.tmpdir") + "file");
FileItem item = createFileItem(testFieldValueBytes, repository);
deserialize(serialize(item));
}
@@ -185,7 +158,7 @@
public void testInvalidRepositoryWithNullChar() throws Exception {
// Create the FileItem
byte[] testFieldValueBytes = createContentBytes(threshold);
- File repository = new File(System.getProperty("java.io.tmpdir"), "\0");
+ File repository = new File(System.getProperty("java.io.tmpdir") + "\0");
FileItem item = createFileItem(testFieldValueBytes, repository);
deserialize(serialize(item));
}
@@ -258,7 +231,7 @@
* Create a FileItem with the specfied content bytes.
*/
private FileItem createFileItem(byte[] contentBytes) {
- return createFileItem(contentBytes, REPO);
+ return createFileItem(contentBytes, null);
}
/**
@@ -306,7 +279,7 @@
} catch (Exception e) {
fail("Exception during deserialization: " + e);
}
- IOUtils.closeQuietly(baos);
+
return result;
}
diff --git a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
index 6de848d..884f8f8 100644
--- a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
+++ b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
@@ -120,7 +120,6 @@
}
}
assertEquals(-1, istream.read());
- istream.close();
}
assertTrue(!iter.hasNext());
listener.checkFinished();
diff --git a/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java b/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java
index 09a4454..27c1ec8 100644
--- a/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java
@@ -396,43 +396,6 @@
assertEquals(2, mappedParameters.get("multi").size());
}
- /**
- * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-239">FILEUPLOAD-239</a>
- */
- @Test
- public void testContentTypeAttachment()
- throws IOException, FileUploadException {
- List<FileItem> fileItems = parseUpload(
- "-----1234\r\n" +
- "content-disposition: form-data; name=\"field1\"\r\n" +
- "\r\n" +
- "Joe Blow\r\n" +
- "-----1234\r\n" +
- "content-disposition: form-data; name=\"pics\"\r\n" +
- "Content-type: multipart/mixed, boundary=---9876\r\n" +
- "\r\n" +
- "-----9876\r\n" +
- "Content-disposition: attachment; filename=\"file1.txt\"\r\n" +
- "Content-Type: text/plain\r\n" +
- "\r\n" +
- "... contents of file1.txt ...\r\n" +
- "-----9876--\r\n" +
- "-----1234--\r\n");
- assertEquals(2, fileItems.size());
-
- FileItem field = fileItems.get(0);
- assertEquals("field1", field.getFieldName());
- assertTrue(field.isFormField());
- assertEquals("Joe Blow", field.getString());
-
- FileItem file = fileItems.get(1);
- assertEquals("pics", file.getFieldName());
- assertFalse(file.isFormField());
- assertEquals("... contents of file1.txt ...", file.getString());
- assertEquals("text/plain", file.getContentType());
- assertEquals("file1.txt", file.getName());
- }
-
private void assertHeaders(String[] pHeaderNames, String[] pHeaderValues,
FileItem pItem, int pIndex) {
for (int i = 0; i < pHeaderNames.length; i++) {
diff --git a/src/test/java/org/apache/commons/fileupload/SizesTest.java b/src/test/java/org/apache/commons/fileupload/SizesTest.java
index 064f413..a2a6536 100644
--- a/src/test/java/org/apache/commons/fileupload/SizesTest.java
+++ b/src/test/java/org/apache/commons/fileupload/SizesTest.java
@@ -255,11 +255,12 @@
assertEquals("file1", item.getFieldName());
assertEquals("foo1.tab", item.getName());
- {
- @SuppressWarnings("resource") // Streams.copy closes the input file
+ try {
InputStream stream = item.openStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Streams.copy(stream, baos, true);
+ } catch (FileUploadIOException e) {
+ fail(e.getMessage());
}
// the second item is over the size max, thus we expect an error
@@ -273,7 +274,6 @@
item = it.next();
try {
- @SuppressWarnings("resource") // Streams.copy closes the input file
InputStream stream = item.openStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Streams.copy(stream, baos, true);