--- old/src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/mimepull/DataHead.java 2013-04-04 15:28:17.224613857 +0200 +++ new/src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/mimepull/DataHead.java 2013-04-04 15:28:17.168613857 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ * lazily using a pull parser, so the part may not have all the data. {@link #read} * and {@link #readOnce} may trigger the actual parsing the message. In fact, * parsing of an attachment part may be triggered by calling {@link #read} methods - * on some other attachemnt parts. All this happens behind the scenes so the + * on some other attachment parts. All this happens behind the scenes so the * application developer need not worry about these details. * * @author Jitendra Kotamraju @@ -84,13 +84,18 @@ } else { try { OutputStream os = new FileOutputStream(f); - InputStream in = readOnce(); - byte[] buf = new byte[8192]; - int len; - while((len=in.read(buf)) != -1) { - os.write(buf, 0, len); + try { + InputStream in = readOnce(); + byte[] buf = new byte[8192]; + int len; + while((len=in.read(buf)) != -1) { + os.write(buf, 0, len); + } + } finally { + if (os != null) { + os.close(); + } } - os.close(); } catch(IOException ioe) { throw new MIMEParsingException(ioe); } @@ -141,6 +146,7 @@ * * @return true if readOnce() is not called before */ + @SuppressWarnings("ThrowableInitCause") private boolean unconsumed() { if (consumedAt != null) { AssertionError error = new AssertionError("readOnce() is already called before. See the nested exception from where it's called."); @@ -195,7 +201,9 @@ @Override public int read(byte b[], int off, int sz) throws IOException { - if(!fetch()) return -1; + if (!fetch()) { + return -1; + } sz = Math.min(sz, len-offset); System.arraycopy(buf,offset,b,off,sz); @@ -203,6 +211,7 @@ return sz; } + @Override public int read() throws IOException { if (!fetch()) { return -1; @@ -244,6 +253,7 @@ return true; } + @Override public void close() throws IOException { super.close(); current = null;