[jboss-svn-commits] JBoss Common SVN: r3427 - declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 5 00:36:38 EDT 2009
Author: ALRubinger
Date: 2009-08-05 00:36:38 -0400 (Wed, 05 Aug 2009)
New Revision: 3427
Modified:
declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java
Log:
[EMB-32] Read bytes from the instream as if you are not a moron
Modified: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java 2009-08-05 04:34:36 UTC (rev 3426)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java 2009-08-05 04:36:38 UTC (rev 3427)
@@ -352,26 +352,39 @@
final int length = connection.getContentLength();
assert length > -1 : "Content length is not known";
final InputStream in = connection.getInputStream();
- byte[] contents = new byte[length];
- int offset = 0;
- while (offset < length)
+ final byte[] contents;
+ try
{
- final int readLength = length - offset;
- int bytesRead = in.read(contents, offset, readLength);
- if (bytesRead == -1)
+ contents = new byte[length];
+ int offset = 0;
+ while (offset < length)
{
- break; // EOF
+ final int readLength = length - offset;
+ int bytesRead = in.read(contents, offset, readLength);
+ if (bytesRead == -1)
+ {
+ break; // EOF
+ }
+ offset += bytesRead;
}
- offset += bytesRead;
}
+ finally
+ {
+ try
+ {
+ // Close up the stream
+ in.close();
+ }
+ catch (final IOException ignore)
+ {
- // Close up the stream
- in.close();
+ }
+ }
// Return the byte array
if (log.isLoggable(Level.FINER))
{
- log.log(Level.FINER, "Read " + contents.length + " bytes for: " + location);
+ log.log(Level.FINER, "Read " + length + " bytes for: " + location);
}
return contents;
}
More information about the jboss-svn-commits
mailing list