summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMikhail Mazursky2013-10-26 02:43:06 (EDT)
committer Mikhail Mazursky2013-10-26 02:43:06 (EDT)
commitc101e55c7f933bd86d65640f49e78d50e46751c5 (patch)
tree8a6f582f0fea112a64ecfefbed49c53a0ee959ad
parenta28e4730ad48012b367900ee5a8b40e95462dde2 (diff)
downloadorg.eclipse.jetty.project-c101e55c7f933bd86d65640f49e78d50e46751c5.zip
org.eclipse.jetty.project-c101e55c7f933bd86d65640f49e78d50e46751c5.tar.gz
org.eclipse.jetty.project-c101e55c7f933bd86d65640f49e78d50e46751c5.tar.bz2
[Bug 420374] Call super.close() in a finally blockrefs/changes/92/17792/1
Signed-off-by: Mikhail Mazursky <mikhail.mazursky@gmail.com>
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartOutputStream.java37
1 files changed, 25 insertions, 12 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartOutputStream.java b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartOutputStream.java
index 024bb63..85cc700 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartOutputStream.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartOutputStream.java
@@ -35,12 +35,12 @@ public class MultiPartOutputStream extends FilterOutputStream
private static final byte[] __CRLF={'\r','\n'};
private static final byte[] __DASHDASH={'-','-'};
- public static String MULTIPART_MIXED="multipart/mixed";
- public static String MULTIPART_X_MIXED_REPLACE="multipart/x-mixed-replace";
+ public static final String MULTIPART_MIXED="multipart/mixed";
+ public static final String MULTIPART_X_MIXED_REPLACE="multipart/x-mixed-replace";
/* ------------------------------------------------------------ */
- private String boundary;
- private byte[] boundaryBytes;
+ private final String boundary;
+ private final byte[] boundaryBytes;
/* ------------------------------------------------------------ */
private boolean inPart=false;
@@ -54,8 +54,15 @@ public class MultiPartOutputStream extends FilterOutputStream
boundary = "jetty"+System.identityHashCode(this)+
Long.toString(System.currentTimeMillis(),36);
boundaryBytes=boundary.getBytes(StringUtil.__ISO_8859_1);
+ }
+
+ public MultiPartOutputStream(OutputStream out, String boundary)
+ throws IOException
+ {
+ super(out);
- inPart=false;
+ this.boundary = boundary;
+ boundaryBytes=boundary.getBytes(StringUtil.__ISO_8859_1);
}
/* ------------------------------------------------------------ */
@@ -66,14 +73,20 @@ public class MultiPartOutputStream extends FilterOutputStream
public void close()
throws IOException
{
- if (inPart)
+ try
+ {
+ if (inPart)
+ out.write(__CRLF);
+ out.write(__DASHDASH);
+ out.write(boundaryBytes);
+ out.write(__DASHDASH);
out.write(__CRLF);
- out.write(__DASHDASH);
- out.write(boundaryBytes);
- out.write(__DASHDASH);
- out.write(__CRLF);
- inPart=false;
- super.close();
+ inPart=false;
+ }
+ finally
+ {
+ super.close();
+ }
}
/* ------------------------------------------------------------ */