svn commit: r759426 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
Author: sebb Date: Sat Mar 28 03:31:42 2009 New Revision: 759426 URL: http://svn.apache.org/viewvc?rev=759426&view=rev Log: Javadoc Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java?rev=759426&r1=759425&r2=759426&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java Sat Mar 28 03:31:42 2009 @@ -21,6 +21,21 @@ import java.io.IOException; import java.io.InputStream; +/** + * Archive input streams are expected to override the + * {...@link #read()} and {...@link #read(byte[] b, int off, int len)} + * methods so that reading from the stream generates EOF for the end of + * data in each entry as well as at the end of the file proper. The + * {...@link #getNextEntry()} method is used to reset the input stream + * ready for reading the data from the next entry. + * + * The input stream classes must also implement a method with the signature: + * + * public static boolean matches(byte[] signature, int length) + * + * which is used by the {...@link ArchiveStreamFactory} to autodetect + * the archive type from the first few bytes of a stream. + */ public abstract class ArchiveInputStream extends InputStream { /**
svn commit: r759425 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers: cpio/CpioArchiveInputStream.java zip/ZipLong.java
Author: sebb Date: Sat Mar 28 03:18:42 2009 New Revision: 759425 URL: http://svn.apache.org/viewvc?rev=759425&view=rev Log: DOcument and simplify Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=759425&r1=759424&r2=759425&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java Sat Mar 28 03:18:42 2009 @@ -257,7 +257,7 @@ throw new IOException("CRC Error"); } } -return -1; +return -1; // EOF for this entry } int tmplength = (int) Math.min(len, this.entry.getSize() - this.entryBytesRead); @@ -267,7 +267,7 @@ int tmpread = this.in.read(b, off, tmplength); // TODO - what about EOF or short reads? -if ((this.entry.getFormat() | FORMAT_NEW_CRC) == FORMAT_NEW_CRC) { +if (this.entry.getFormat() == FORMAT_NEW_CRC) { for (int pos = 0; pos < tmpread; pos++) { this.crc += b[pos] & 0xFF; } Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java?rev=759425&r1=759424&r2=759425&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java Sat Mar 28 03:18:42 2009 @@ -42,7 +42,10 @@ private final long value; +/** Central File Header Signature */ public static final ZipLong CFH_SIG = new ZipLong(0X02014B50L); + +/** Local File Header Signature */ public static final ZipLong LFH_SIG = new ZipLong(0X04034B50L); /**
svn commit: r759421 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
Author: sebb Date: Sat Mar 28 02:39:01 2009 New Revision: 759421 URL: http://svn.apache.org/viewvc?rev=759421&view=rev Log: Not needed, as it duplicates the code in InputStream Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=759421&r1=759420&r2=759421&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Sat Mar 28 02:39:01 2009 @@ -399,12 +399,6 @@ hasHitEOF = b; } - -// used to be implemented via FilterInputStream -public int read(byte[] b) throws IOException { -return read(b, 0, b.length); -} - // ArchiveInputStream public static boolean matches(byte[] signature, int length) {
svn commit: r759415 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
Author: sebb Date: Sat Mar 28 01:26:22 2009 New Revision: 759415 URL: http://svn.apache.org/viewvc?rev=759415&view=rev Log: Not thread-safe Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=759415&r1=759414&r2=759415&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Sat Mar 28 01:26:22 2009 @@ -27,7 +27,7 @@ /** * Implements the "ar" archive format as an input stream. * - * This class is thread-safe if the InputStream is thread-safe. + * @NotThreadSafe * */ public class ArArchiveInputStream extends ArchiveInputStream {
svn commit: r759403 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
Author: sebb Date: Sat Mar 28 00:07:58 2009 New Revision: 759403 URL: http://svn.apache.org/viewvc?rev=759403&view=rev Log: Oops, did not mean to commit that change to the file Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java?rev=759403&r1=759402&r2=759403&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Sat Mar 28 00:07:58 2009 @@ -46,7 +46,7 @@ * * @see Simple8BitZipEncoding#Simple8BitZipEncoding(char[]) */ -SimpleEncodingHolderxx(char [] highChars) { +SimpleEncodingHolder(char [] highChars) { this.highChars = highChars; }
svn commit: r759399 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/jar/ archivers/tar/ archivers/zip/ compressors/bzip2/
Author: sebb Date: Sat Mar 28 00:04:36 2009 New Revision: 759399 URL: http://svn.apache.org/viewvc?rev=759399&view=rev Log: Not thread-safe Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java?rev=759399&r1=759398&r2=759399&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java Sat Mar 28 00:04:36 2009 @@ -27,6 +27,10 @@ import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +/** + * + * @NotThreadSafe + */ public class JarArchiveEntry extends ZipArchiveEntry implements ArchiveEntry { private Attributes manifestAttributes = null; Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java?rev=759399&r1=759398&r2=759399&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java Sat Mar 28 00:04:36 2009 @@ -25,6 +25,11 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; +/** + * Implements an input stream that can read entries from jar files. + * + * @NotThreadSafe + */ public class JarArchiveInputStream extends ZipArchiveInputStream { public JarArchiveInputStream( final InputStream inputStream ) { Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java?rev=759399&r1=759398&r2=759399&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/
svn commit: r759397 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ archivers/cpio/ archivers/tar/ archivers/zip/ changes/ compressors/ utils/
Author: sebb Date: Sat Mar 28 00:03:11 2009 New Revision: 759397 URL: http://svn.apache.org/viewvc?rev=759397&view=rev Log: These classes are immutable, i.e. thread-safe Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/Change.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/IOUtils.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=759397&r1=759396&r2=759397&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Sat Mar 28 00:03:11 2009 @@ -40,7 +40,7 @@ * implementation from super of course) * * TODO add example here - * + * @Immutable */ public class ArchiveStreamFactory { Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java?rev=759397&r1=759396&r2=759397&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java Sat Mar 28 00:03:11 2009 @@ -18,6 +18,11 @@ */ package org.apache.commons.compress.archivers.cpio; +/** + * Package private utility class for Cpio + * + * @Immutable + */ class CpioUtil { /** * Converts a byte array to a long. Halfwords can be swaped with setting Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java?rev=759397&r1=759396&r2=759397&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java Sat Mar 28 00:03:11 2009 @@ -21,6 +21,7 @@ /** * This class provides static utility methods to work with byte streams. * + * @Immutable */ // CheckStyle:HideUtilityClassConstructorCheck OFF (bc) public class TarUtils { Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java?rev=759397&r1=759396&r2=759397&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java Sat Mar 28 00:03:11 2009 @@ -38,6 +38,7 @@ * available. * * The methods of this class are reentrant. + * @Immutable */ class FallbackZipEncoding implements ZipEncoding { private final String charset; Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java?rev=759397&r1=759396&r2=759397&view=diff ==
svn commit: r759396 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
Author: sebb Date: Sat Mar 28 00:00:30 2009 New Revision: 759396 URL: http://svn.apache.org/viewvc?rev=759396&view=rev Log: No need to be public class Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java?rev=759396&r1=759395&r2=759396&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java Sat Mar 28 00:00:30 2009 @@ -33,10 +33,10 @@ * * You should never have a need to access this class directly. * TarBuffers are created by Tar IO Streams. - * + * @NotThreadSafe */ -public class TarBuffer { +class TarBuffer { // Not public, because only needed by the Tar IO streams /** Default record size */ public static final int DEFAULT_RCDSIZE = (512);
svn commit: r759392 - /commons/proper/cli/trunk/pom.xml
Author: sebb Date: Fri Mar 27 23:37:56 2009 New Revision: 759392 URL: http://svn.apache.org/viewvc?rev=759392&view=rev Log: JUnit 3.8.2 is best for Java 1.4 Modified: commons/proper/cli/trunk/pom.xml Modified: commons/proper/cli/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/pom.xml?rev=759392&r1=759391&r2=759392&view=diff == --- commons/proper/cli/trunk/pom.xml (original) +++ commons/proper/cli/trunk/pom.xml Fri Mar 27 23:37:56 2009 @@ -122,7 +122,7 @@ junit junit - 3.8.1 + 3.8.2 test
svn commit: r759371 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java
Author: sebb Date: Fri Mar 27 22:02:20 2009 New Revision: 759371 URL: http://svn.apache.org/viewvc?rev=759371&view=rev Log: Fix malicious code / thread-safety bug Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java?rev=759371&r1=759370&r2=759371&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java Fri Mar 27 22:02:20 2009 @@ -22,6 +22,10 @@ import java.util.Date; import java.util.zip.CRC32; +/** + * Utility class for handling DOS and Java time conversions. + * @Immutable + */ public abstract class ZipUtil { /** * Smallest date/time ZIP can handle. @@ -50,7 +54,7 @@ // here will improve the readablity int year = time.getYear() + 1900; if (year < 1980) { -return DOS_TIME_MIN; +return (byte[]) DOS_TIME_MIN.clone(); // stop callers from changing the array } int month = time.getMonth() + 1; long value = ((year - 1980) << 25) Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java?rev=759371&r1=759370&r2=759371&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java Fri Mar 27 22:02:20 2009 @@ -74,4 +74,11 @@ ZipUtil.adjustToLong(2 * Integer.MAX_VALUE)); } +public void testMinTime(){ +byte[] b1 = ZipUtil.toDosTime(0); +byte b10 = b1[0]; // Save the first byte +b1[0]++; // change it +byte[] b2 = ZipUtil.toDosTime(0); // get the same time +assertEquals(b10,b2[0]); // first byte should still be the same +} }
svn commit: r759359 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java
Author: sebb Date: Fri Mar 27 21:37:14 2009 New Revision: 759359 URL: http://svn.apache.org/viewvc?rev=759359&view=rev Log: Class was not thread-safe: - external byte array was stored directly - List was created and then modified via the final variable Fixed by copying byte array and storing List once as unmodifiable List Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java?rev=759359&r1=759358&r2=759359&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java Fri Mar 27 21:37:14 2009 @@ -42,6 +42,7 @@ * implementation, Cp437 and Cp850. * * The methods of this class are reentrant. + * @Immutable */ class Simple8BitZipEncoding implements ZipEncoding { @@ -88,17 +89,17 @@ * stored as an array of 128 chars. */ public Simple8BitZipEncoding(char[] highChars) { -this.highChars = highChars; -this.reverseMapping = new ArrayList(this.highChars.length); +this.highChars = (char[]) highChars.clone(); +List temp = new ArrayList(this.highChars.length); byte code = 127; for (int i = 0; i < this.highChars.length; ++i) { -this.reverseMapping.add(new Simple8BitChar(++code, - this.highChars[i])); +temp.add(new Simple8BitChar(++code, this.highChars[i])); } -Collections.sort(this.reverseMapping); +Collections.sort(temp); +this.reverseMapping = Collections.unmodifiableList(temp); } /**
svn commit: r759355 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar: ArArchiveEntry.java ArArchiveInputStream.java ArArchiveOutputStream.java
Author: sebb Date: Fri Mar 27 21:13:51 2009 New Revision: 759355 URL: http://svn.apache.org/viewvc?rev=759355&view=rev Log: Javadoc - thread safety Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=759355&r1=759354&r2=759355&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java Fri Mar 27 21:13:51 2009 @@ -22,6 +22,8 @@ /** * Represents an archive entry in the "ar" format. + * + * @Immutable */ public class ArArchiveEntry implements ArchiveEntry { Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=759355&r1=759354&r2=759355&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Fri Mar 27 21:13:51 2009 @@ -25,7 +25,10 @@ import org.apache.commons.compress.archivers.ArchiveInputStream; /** - * Implements the "ar" archive format as an input stream + * Implements the "ar" archive format as an input stream. + * + * This class is thread-safe if the InputStream is thread-safe. + * */ public class ArArchiveInputStream extends ArchiveInputStream { Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=759355&r1=759354&r2=759355&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Fri Mar 27 21:13:51 2009 @@ -25,7 +25,9 @@ import org.apache.commons.compress.archivers.ArchiveOutputStream; /** - * Implements the "ar" archive format as an output stream + * Implements the "ar" archive format as an output stream. + * + * @NotThreadSafe */ public class ArArchiveOutputStream extends ArchiveOutputStream {
svn commit: r759352 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
Author: tcurdt Date: Fri Mar 27 21:08:27 2009 New Revision: 759352 URL: http://svn.apache.org/viewvc?rev=759352&view=rev Log: tracked down the problem of https://issues.apache.org/jira/browse/COMPRESS-11 Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=759352&r1=759351&r2=759352&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Fri Mar 27 21:08:27 2009 @@ -107,10 +107,16 @@ out.close(); } + assertEquals(282, output.length()); + final File output2 = new File(dir, "bla2.ar"); + int copied = 0; + int deleted = 0; + { // remove all but one file + final InputStream is = new FileInputStream(output); final OutputStream os = new FileOutputStream(output2); final ArchiveOutputStream aos = new ArchiveStreamFactory().createArchiveOutputStream("ar", os); @@ -124,8 +130,11 @@ if ("test1.xml".equals(entry.getName())) { aos.putArchiveEntry(entry); IOUtils.copy(ais, aos); + aos.closeArchiveEntry(); + copied++; } else { IOUtils.copy(ais, new ByteArrayOutputStream()); + deleted++; } } @@ -135,7 +144,11 @@ os.close(); } + assertEquals(1, copied); + assertEquals(1, deleted); + assertEquals(144, output2.length()); + long files = 0; long sum = 0; { @@ -150,11 +163,13 @@ IOUtils.copy(ais, new ByteArrayOutputStream()); sum += entry.getLength(); + files++; } ais.close(); is.close(); } + assertEquals(1, files); assertEquals(76, sum); }
svn commit: r759349 - /commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java
Author: rgoers Date: Fri Mar 27 20:58:25 2009 New Revision: 759349 URL: http://svn.apache.org/viewvc?rev=759349&view=rev Log: Don't print the xml during the unit test Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java?rev=759349&r1=759348&r2=759349&view=diff == --- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java (original) +++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java Fri Mar 27 20:58:25 2009 @@ -125,7 +125,7 @@ public void testMerge() throws ConfigurationException { -combiner.setDebugStream(System.out); +//combiner.setDebugStream(System.out); HierarchicalConfiguration config = createCombinedConfiguration(); config.setExpressionEngine(new XPathExpressionEngine()); assertEquals("Wrong number of Channels", 3, config.getMaxIndex("Channels/Channel"));
svn commit: r759346 - in /commons/proper/configuration/trunk: conf/ src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/tree/ src/test/org/apache/commons/configuration
Author: rgoers Date: Fri Mar 27 20:53:16 2009 New Revision: 759346 URL: http://svn.apache.org/viewvc?rev=759346&view=rev Log: CONFIGURATION-378 Add MergeCombiner Added: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/tree/MergeCombiner.java - copied, changed from r757541, commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/tree/OverrideCombiner.java commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestMergeCombiner.java - copied, changed from r757541, commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/tree/TestOverrideCombiner.java Modified: commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml commons/proper/configuration/trunk/conf/testcombine1.xml commons/proper/configuration/trunk/conf/testcombine2.xml commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/tree/NodeCombiner.java commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java commons/proper/configuration/trunk/xdocs/changes.xml commons/proper/configuration/trunk/xdocs/userguide/howto_combinedconfiguration.xml Modified: commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml?rev=759346&r1=759345&r2=759346&view=diff == --- commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml (original) +++ commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml Fri Mar 27 20:53:16 2009 @@ -5,6 +5,7 @@ + Modified: commons/proper/configuration/trunk/conf/testcombine1.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/conf/testcombine1.xml?rev=759346&r1=759345&r2=759346&view=diff == --- commons/proper/configuration/trunk/conf/testcombine1.xml (original) +++ commons/proper/configuration/trunk/conf/testcombine1.xml Fri Mar 27 20:53:16 2009 @@ -49,4 +49,15 @@ + + + My Channel + + + more test 2 data + + + Test Channel + + Modified: commons/proper/configuration/trunk/conf/testcombine2.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/conf/testcombine2.xml?rev=759346&r1=759345&r2=759346&view=diff == --- commons/proper/configuration/trunk/conf/testcombine2.xml (original) +++ commons/proper/configuration/trunk/conf/testcombine2.xml Fri Mar 27 20:53:16 2009 @@ -45,4 +45,18 @@ + + + Channel 1 + test 1 data + + + Channel 2 + test 2 data + + + Channel 3 + test 3 data + + Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java?rev=759346&r1=759345&r2=759346&view=diff == --- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java (original) +++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java Fri Mar 27 20:53:16 2009 @@ -36,6 +36,7 @@ import org.apache.commons.configuration.tree.DefaultExpressionEngine; import org.apache.commons.configuration.tree.ExpressionEngine; import org.apache.commons.configuration.tree.NodeAddData; +import org.apache.commons.configuration.tree.ViewNode; import org.apache.commons.lang.StringUtils; /** @@ -1331,12 +1332,28 @@ for (Iterator it = getChildren().iterator(); it.hasNext() && !visitor.terminate();) { -((Node) it.next()).visit(visitor, key); +Object obj = it.next(); +if (obj instanceof ViewNode) +{ +new Node((ViewNode)obj).visit(visitor, key); +} +else +{ +((Node) obj).visit(visitor, key); +} } for (Iterator it = getAttributes().iterator(); it.hasNext() && !visitor.terminate();) { -((Node) it.next()).visit(visitor, key); +Object obj = it.next(); +if (obj instanceof ViewNode) +{ +new No
svn commit: r759344 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
Author: sebb Date: Fri Mar 27 20:47:56 2009 New Revision: 759344 URL: http://svn.apache.org/viewvc?rev=759344&view=rev Log: Make entry "constants" final Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=759344&r1=759343&r2=759344&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java Fri Mar 27 20:47:56 2009 @@ -134,6 +134,8 @@ * * The MAGIC numbers and other constants are defined in {...@link CpioConstants} * @see "http://people.freebsd.org/~kientzle/libarchive/man/cpio.5.txt"; + * + * @NotThreadSafe */ public class CpioArchiveEntry implements CpioConstants, ArchiveEntry { @@ -142,13 +144,13 @@ /** * See {...@link CpioArchiveEntry#setFormat(short)} for possible values. */ -private short fileFormat = 0; // Default chosen so checkNewFormat() and checkOldFormat() both fail +private final short fileFormat; /** The number of bytes in each header record; depends on the file format */ -private int headerSize = -1; +private final int headerSize; /** The boundary to which the header and data elements are aligned: 0, 2 or 4 bytes */ -private int alignmentBoundary; +private final int alignmentBoundary; // Header fields @@ -184,9 +186,37 @@ * * @param format *The cpio format for this entry. + * + * Possible format values are: + * + * CpioConstants.FORMAT_NEW + * CpioConstants.FORMAT_NEW_CRC + * CpioConstants.FORMAT_OLD_BINARY + * CpioConstants.FORMAT_OLD_ASCII + * */ public CpioArchiveEntry(final short format) { -setFormat(format); +switch (format) { +case FORMAT_NEW: +this.headerSize = 110; +this.alignmentBoundary = 4; +break; +case FORMAT_NEW_CRC: +this.headerSize = 110; +this.alignmentBoundary = 4; +break; +case FORMAT_OLD_ASCII: +this.headerSize = 76; +this.alignmentBoundary = 0; +break; +case FORMAT_OLD_BINARY: +this.headerSize = 26; +this.alignmentBoundary = 2; +break; +default: +throw new IllegalArgumentException("Unknown header type"); +} +this.fileFormat = format; } /** @@ -587,43 +617,6 @@ } /** - * Set the header format for this entry. - * - * Possible values are: - * - * {...@link CpioConstants.FORMAT_NEW} - * {...@link CpioConstants.FORMAT_NEW_CRC} - * {...@link CpioConstants.FORMAT_OLD_BINARY} - * {...@link CpioConstants.FORMAT_OLD_ASCII} - * - * @param format - *The format to set. - */ -final void setFormat(final short format) { -switch (format) { -case FORMAT_NEW: -this.headerSize = 110; -this.alignmentBoundary = 4; -break; -case FORMAT_NEW_CRC: -this.headerSize = 110; -this.alignmentBoundary = 4; -break; -case FORMAT_OLD_ASCII: -this.headerSize = 76; -this.alignmentBoundary = 0; -break; -case FORMAT_OLD_BINARY: -this.headerSize = 26; -this.alignmentBoundary = 2; -break; -default: -throw new IllegalArgumentException("Unknown header type"); -} -this.fileFormat = format; -} - -/** * Set the group id. * * @param gid
svn commit: r759343 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
Author: sebb Date: Fri Mar 27 20:47:04 2009 New Revision: 759343 URL: http://svn.apache.org/viewvc?rev=759343&view=rev Log: Caller must already have set the entry format Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=759343&r1=759342&r2=759343&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Fri Mar 27 20:47:04 2009 @@ -148,9 +148,7 @@ } final short format = e.getFormat(); -if (format == 0) {// Not yet initialised -e.setFormat(this.entryFormat); -} else if (format != this.entryFormat){ +if (format != this.entryFormat){ throw new IOException("Header format: "+format+" does not match existing format: "+this.entryFormat); }
svn commit: r759339 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Author: sebb Date: Fri Mar 27 20:45:58 2009 New Revision: 759339 URL: http://svn.apache.org/viewvc?rev=759339&view=rev Log: Recursive delete of temporary directories Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=759339&r1=759338&r2=759339&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Fri Mar 27 20:45:58 2009 @@ -76,10 +76,19 @@ String[] s = f.list(); if (s != null) { for (int i = 0; i < s.length; i++) { -new File(f, s[i]).delete(); +final File file = new File(f, s[i]); +if (file.isDirectory()){ +rmdir(file); +} +boolean ok = file.delete(); +if (!ok && file.exists()){ +System.out.println("Failed to delete "+s[i]+" in "+f.getPath()); +} } } -f.delete(); +if (!f.delete()){ +throw new Error("Failed to delete "+f.getPath()); +} } /** @@ -240,5 +249,6 @@ } } assertEquals(0, expected.size()); +rmdir(result); } }
svn commit: r759338 - in /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers: JarTestCase.java ZipTestCase.java
Author: sebb Date: Fri Mar 27 20:44:59 2009 New Revision: 759338 URL: http://svn.apache.org/viewvc?rev=759338&view=rev Log: Close files Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java?rev=759338&r1=759337&r2=759338&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java Fri Mar 27 20:44:59 2009 @@ -79,6 +79,7 @@ out.close(); in.close(); +is.close(); } public void testJarUnarchiveAll() throws Exception { @@ -102,6 +103,7 @@ } in.close(); + is.close(); } } Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java?rev=759338&r1=759337&r2=759338&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java Fri Mar 27 20:44:59 2009 @@ -57,10 +57,9 @@ } finally { if (os != null) { os.close(); -} else { -out.close(); } } +out.close(); // Unarchive the same List results = new ArrayList(); @@ -86,10 +85,9 @@ } finally { if (in != null) { in.close(); -} else { -is.close(); } } +is.close(); assertEquals(results.size(), 2); File result = (File)results.get(0);
svn commit: r759335 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
Author: tcurdt Date: Fri Mar 27 20:35:23 2009 New Revision: 759335 URL: http://svn.apache.org/viewvc?rev=759335&view=rev Log: fixed the testcase Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=759335&r1=759334&r2=759335&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Fri Mar 27 20:35:23 2009 @@ -123,7 +123,11 @@ if ("test1.xml".equals(entry.getName())) { aos.putArchiveEntry(entry); + IOUtils.copy(ais, aos); + } else { + IOUtils.copy(ais, new ByteArrayOutputStream()); } + } ais.close(); aos.close(); @@ -136,15 +140,14 @@ { final InputStream is = new FileInputStream(output2); - final ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(is); + final ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is)); while(true) { final ArArchiveEntry entry = (ArArchiveEntry)ais.getNextEntry(); if (entry == null) { break; } - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - IOUtils.copy(ais, os); + IOUtils.copy(ais, new ByteArrayOutputStream()); sum += entry.getLength(); } @@ -152,7 +155,7 @@ is.close(); } - assertEquals(0, sum); + assertEquals(76, sum); }
svn commit: r759326 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
Author: tcurdt Date: Fri Mar 27 20:09:40 2009 New Revision: 759326 URL: http://svn.apache.org/viewvc?rev=759326&view=rev Log: reproduce https://issues.apache.org/jira/browse/COMPRESS-11 Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=759326&r1=759325&r2=759326&view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Fri Mar 27 20:09:40 2009 @@ -18,18 +18,20 @@ */ package org.apache.commons.compress.archivers; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import org.apache.commons.compress.AbstractTestCase; import org.apache.commons.compress.archivers.ar.ArArchiveEntry; import org.apache.commons.compress.utils.IOUtils; -import org.apache.commons.compress.AbstractTestCase; - public final class ArTestCase extends AbstractTestCase { + public void testArArchiveCreation() throws Exception { final File output = new File(dir, "bla.ar"); @@ -71,7 +73,7 @@ // UnArArchive Operation final File input = output; final InputStream is = new FileInputStream(input); - final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("ar", is); + final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is)); final ArArchiveEntry entry = (ArArchiveEntry)in.getNextEntry(); File target = new File(dir, entry.getName()); @@ -84,4 +86,74 @@ is.close(); } + public void testArDelete() throws Exception { + final File output = new File(dir, "bla.ar"); + + { + // create + final File file1 = getFile("test1.xml"); + final File file2 = getFile("test2.xml"); + + final OutputStream out = new FileOutputStream(output); + final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("ar", out); + os.putArchiveEntry(new ArArchiveEntry("test1.xml", file1.length())); + IOUtils.copy(new FileInputStream(file1), os); + os.closeArchiveEntry(); + + os.putArchiveEntry(new ArArchiveEntry("test2.xml", file2.length())); + IOUtils.copy(new FileInputStream(file2), os); + os.closeArchiveEntry(); + os.close(); + out.close(); + } + + final File output2 = new File(dir, "bla2.ar"); + + { + // remove all but one file + final InputStream is = new FileInputStream(output); + final OutputStream os = new FileOutputStream(output2); + final ArchiveOutputStream aos = new ArchiveStreamFactory().createArchiveOutputStream("ar", os); + final ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is)); + while(true) { + final ArArchiveEntry entry = (ArArchiveEntry)ais.getNextEntry(); + if (entry == null) { + break; + } + + if ("test1.xml".equals(entry.getName())) { + aos.putArchiveEntry(entry); + } + } + ais.close(); + aos.close(); + is.close(); + os.close(); + } + + + long sum = 0; + + { + final InputStream is = new FileInputStream(output2); + final ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(is); + while(true) { + final ArArchiveEntry entry = (ArArchiveEntry)ais.getNextEntry(); +
svn commit: r759308 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2: BZip2CompressorInputStream.java BZip2CompressorOutputStream.java
Author: sebb Date: Fri Mar 27 19:19:44 2009 New Revision: 759308 URL: http://svn.apache.org/viewvc?rev=759308&view=rev Log: Name changed; remove unnecessary casts Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java?rev=759308&r1=759307&r2=759308&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java Fri Mar 27 19:19:44 2009 @@ -96,7 +96,7 @@ private BZip2CompressorInputStream.Data data; /** - * Constructs a new CBZip2InputStream which decompresses bytes read from the + * Constructs a new BZip2CompressorInputStream which decompresses bytes read from the * specified stream. * * Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=759308&r1=759307&r2=759308&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Fri Mar 27 19:19:44 2009 @@ -30,7 +30,7 @@ * * The compression requires large amounts of memory. Thus you should call the * {...@link #close() close()} method as soon as possible, to force - * CBZip2OutputStream to release the allocated memory. + * BZip2CompressorOutputStream to release the allocated memory. * * * You can shrink the amount of allocated memory and maybe raise @@ -47,7 +47,7 @@ * * * To get the memory required for decompression by {...@link - * CBZip2InputStream CBZip2InputStream} use + * BZip2CompressorInputStream} use * * *65k + (5 * blocksize)
. @@ -112,7 +112,7 @@ * * * - * For decompression CBZip2InputStream allocates less memory if the + * For decompression BZip2CompressorInputStream allocates less memory if the * bzipped input is smaller than one block. * * @@ -1620,7 +1620,7 @@ while (true) { while (unLo <= unHi) { -final int n = ((int) block[fmap[unLo] + d1] & 0xff) +final int n = (block[fmap[unLo] + d1] & 0xff) - med; if (n == 0) { final int temp = fmap[unLo]; @@ -1634,7 +1634,7 @@ } while (unLo <= unHi) { -final int n = ((int) block[fmap[unHi] + d1] & 0xff) +final int n = (block[fmap[unHi] + d1] & 0xff) - med; if (n == 0) { final int temp = fmap[unHi];
svn commit: r759305 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Author: sebb Date: Fri Mar 27 18:59:24 2009 New Revision: 759305 URL: http://svn.apache.org/viewvc?rev=759305&view=rev Log: unused Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=759305&r1=759304&r2=759305&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Fri Mar 27 18:59:24 2009 @@ -101,7 +101,6 @@ if (current != null) { closeEntry(); } -int x = 0, count = 0; byte[] lfh = new byte[LFH_LEN]; try { readFully(lfh);
svn commit: r759287 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio: CpioArchiveInputStream.java CpioArchiveOutputStream.java
Author: sebb Date: Fri Mar 27 17:51:03 2009 New Revision: 759287 URL: http://svn.apache.org/viewvc?rev=759287&view=rev Log: Simplify code by using getXXXPadCount() methods Align variable names (was entry and cpioEntry) Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=759287&r1=759286&r2=759287&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java Fri Mar 27 17:51:03 2009 @@ -200,13 +200,11 @@ return this.entry; } -private long skip(final long count, final int border) throws IOException { -long skip = count % border; -if (skip > 0) { -skip = this.in.skip(border - skip); -// TODO - what if not enough bytes are skipped? +private void skip(int bytes) throws IOException{ +final byte[] buff = new byte[4]; // Cannot be more than 3 bytes +if (bytes > 0) { +readFully(buff, 0, bytes); } -return skip; } /** @@ -251,15 +249,10 @@ if (this.entry == null || this.entryEOF) { return -1; } -// N.B. These checks assume format is not 0 - otherwise condition is always true if (this.entryBytesRead == this.entry.getSize()) { -if ((this.entry.getFormat() | FORMAT_NEW_MASK) == FORMAT_NEW_MASK) { -skip(this.entry.getSize(), 4); -} else if ((this.entry.getFormat() | FORMAT_OLD_BINARY) == FORMAT_OLD_BINARY) { -skip(this.entry.getSize(), 2); -} // No need to skip for FORMAT_OLD_ASCII +skip(entry.getDataPadCount()); this.entryEOF = true; -if ((this.entry.getFormat() | FORMAT_NEW_CRC) == FORMAT_NEW_CRC) { +if (this.entry.getFormat() == FORMAT_NEW_CRC) { if (this.crc != this.entry.getChksum()) { throw new IOException("CRC Error"); } @@ -345,7 +338,7 @@ // TODO - change this to throw new IOException("Mode 0 only allowed in the trailer. Found: "+name).printStackTrace(); } -skip(ret.getHeaderSize() + namesize, 4); +skip(ret.getHeaderPadCount()); return ret; } @@ -383,7 +376,7 @@ long namesize = readBinaryLong(2, swapHalfWord); ret.setSize(readBinaryLong(4, swapHalfWord)); ret.setName(readCString((int) namesize)); -skip(ret.getHeaderSize() + namesize, 2); +skip(ret.getHeaderPadCount()); return ret; } Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=759287&r1=759286&r2=759287&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Fri Mar 27 17:51:03 2009 @@ -60,7 +60,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements CpioConstants { -private CpioArchiveEntry cpioEntry; +private CpioArchiveEntry entry; private boolean closed = false; @@ -140,7 +140,7 @@ */ public void putNextEntry(final CpioArchiveEntry e) throws IOException { ensureOpen(); -if (this.cpioEntry != null) { +if (this.entry != null) { closeArchiveEntry(); // close previous entry } if (e.getTime() == -1) { @@ -159,7 +159,7 @@ } writeHeader(e); -this.cpioEntry = e; +this.entry = e; this.written = 0; } @@ -200,7 +200,7 @@ writeAsciiLong(entry.getName().length() + 1, 8, 16); writeAsciiLong(entry.getChksum(), 8, 16); writeCString(entry.getName()); -pad(entry.getHeaderSize() + entry.getName().length() + 1, 4); +pad(entry.getHeaderPadCount()); } private void writeOldAsciiEntry(final CpioArchiveEntry entry) @@ -231,7 +231,7 @@
svn commit: r759283 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
Author: sebb Date: Fri Mar 27 17:44:16 2009 New Revision: 759283 URL: http://svn.apache.org/viewvc?rev=759283&view=rev Log: Add alignmentBoundary and pad calculation methods to simplify the job for users. Update some Javadoc headerSize can only be an int. Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=759283&r1=759282&r2=759283&view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java Fri Mar 27 17:44:16 2009 @@ -81,11 +81,16 @@ * FIFOs and directories * * All fields are unsigned short fields with 16-bit integer values + * apart from c_mtime and c_filesize which are 32-bit integer values * * + * If necessary, the filename and file data are padded with a NUL byte to an even length + * * Special files, directories, and the trailer are recorded with * the h_filesize field equal to 0. * + * In the ASCII version of this format, the 16-bit entries are represented as 6-byte octal numbers, + * and the 32-bit entries are represented as 11-byte octal numbers. No padding is added. * * NEW FORMAT * @@ -140,12 +145,16 @@ private short fileFormat = 0; // Default chosen so checkNewFormat() and checkOldFormat() both fail /** The number of bytes in each header record; depends on the file format */ -private long headerSize = -1; +private int headerSize = -1; + +/** The boundary to which the header and data elements are aligned: 0, 2 or 4 bytes */ +private int alignmentBoundary; // Header fields private long chksum = 0; +/** Number of bytes in the file */ private long filesize = 0; private long gid = 0; @@ -227,8 +236,10 @@ /** * Get the checksum. + * Only supported for the new formats. * * @return Returns the checksum. + * @throws UnsupportedOperationException if the format is not a new format */ public long getChksum() { checkNewFormat(); @@ -265,6 +276,7 @@ * Get the minor device id * * @return Returns the minor device id. + * @throws UnsupportedOperationException if format is not a new format */ public long getDeviceMin() { checkNewFormat(); @@ -275,10 +287,6 @@ * Get the filesize. * * @return Returns the filesize. - */ -/* - * (non-Javadoc) - * * @see org.apache.commons.compress.archivers.ArchiveEntry#getSize() */ public long getSize() { @@ -304,15 +312,54 @@ } /** - * Get the size of this entry on the stream + * Get the header size for this CPIO format * - * @return Returns the size. + * @return Returns the header size in bytes. */ -public long getHeaderSize() { +public int getHeaderSize() { return this.headerSize; } /** + * Get the alignment boundary for this CPIO format + * + * @return Returns the aligment boundary (0, 2, 4) in bytes + */ +public int getAlignmentBoundary() { +return this.alignmentBoundary; +} + +/** + * Get the number of bytes needed to pad the header to the alignment boundary. + * + * @return the number of bytes needed to pad the header (0,1,2,3) + */ +public int getHeaderPadCount(){ +if (this.alignmentBoundary == 0) return 0; +int size = this.headerSize+this.name.length()+1; // Name has terminating null +int remain = size % this.alignmentBoundary; +if (remain > 0){ +return this.alignmentBoundary - remain; +} +return 0; +} + +/** + * Get the number of bytes needed to pad the data to the alignment boundary. + * + * @return the number of bytes needed to pad the data (0,1,2,3) + */ +public int getDataPadCount(){ +if (this.alignmentBoundary == 0) return 0; +long size = this.filesize; +int remain = (int) (size % this.alignmentBoundary); +if (remain > 0){ +return this.alignmentBoundary - remain; +} +return 0; +} + +/** * Set the inode. * * @return Returns the inode. @@ -556,15 +603,19 @@ switch (format) { case FORMAT_NEW: this.headerSize = 110; +this.alignmentBoundary = 4; break; case FORMAT_NEW_CRC: this.headerSize = 110; +this.ali
svn commit: r759200 - /commons/proper/compress/trunk/src/site/xdoc/index.xml
Author: bodewig Date: Fri Mar 27 16:30:59 2009 New Revision: 759200 URL: http://svn.apache.org/viewvc?rev=759200&view=rev Log: remove links to broken examples, update the documentation a little, fix link to svn Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=759200&r1=759199&r2=759200&view=diff == --- commons/proper/compress/trunk/src/site/xdoc/index.xml (original) +++ commons/proper/compress/trunk/src/site/xdoc/index.xml Fri Mar 27 16:30:59 2009 @@ -25,45 +25,47 @@ -Commons Compress defines an API for working with tar, zip and bzip2 files. +Commons Compress defines an API for working with ar, +cpio, tar, zip, gzip and bzip2 files. -The code in this component came from Avalon's Excalibur, but originally from Ant, -as far as life in Apache goes. The tar package is originally Tim Endres' public -domain package. The bzip2 package is based on the work done by Keiron Liddle. -It has migrated via: -Ant -> Avalon-Excalibur -> Commons-IO -> Commons-Compress. +The code in this component has many origins: + + The bzip2, tar and zip support came from Avalon's +Excalibur, but originally from Ant, as far as life in +Apache goes. The tar package is originally Tim Endres' +public domain package. The bzip2 package is based on +the work done by Keiron Liddle. It has migrated +via: Ant -> Avalon-Excalibur -> Commons-IO +-> Commons-Compress. + The cpio package has been contributed by Markus Kuss +and +the http://jrpm.sourceforge.net/";>jRPM +project. + - -This component has been promoted to Commons proper -The code is unreleased -Methods and classes can and will appear and disappear without warning -If you like the code and want to push it towards a release, join the mailing list! - + +This component has been promoted to Commons proper +The code is unreleased +Methods and classes can and will appear and +disappear without warning +If you like the code and want to push it towards a +release, join the mailing list! + - -The Javadoc of the latest SVN -The http://svn.apache.org/viewvc/commons/compress/";>SVN repository can be browsed. - - -There are also 2 example for the bzip2 API: - - - -Bzip2Compress - - -Bzip2UnCompress - + +The Javadoc of the latest SVN +The http://svn.apache.org/viewvc/commons/proper/compress/";>SVN +repository can be browsed. - -None. - + +None. +
svn commit: r759195 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ archivers/ar/ archivers/cpio/ archivers/jar/ archivers/tar/ archivers/zip/ changes/ compre
Author: bodewig Date: Fri Mar 27 16:21:56 2009 New Revision: 759195 URL: http://svn.apache.org/viewvc?rev=759195&view=rev Log: minimal package level javadocs Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/package.html (with props) Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html?rev=759195&view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html Fri Mar 27 16:21:56 2009 @@ -0,0 +1,24 @@ + + + +Provides stream classes for reading and writing archives using + the AR format. + + Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html -- svn:eol-style = native Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html?rev=759195&view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html Fri Mar 27 16:21:56 2009 @@ -0,0 +1,24 @@ + + + +Provides stream classes for reading and writing archives using + the CPIO format. + + Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html -- svn:eol-style = native Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html?rev=759195&view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html Fri Mar 27 16:21:56 2009 @@ -0,0 +1,25 @@ + + + +Provides stream classes for reading and writing archives using + the ZIP format with some extensions for the special case of JAR + archives. + + Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html -- svn:eol-style = native Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/package.html URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/package.html?rev=759195&view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/package.html (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/package.html Fri Mar 27 16:21:56 2009 @@ -0,0 +1,24 @@ + + + +Provides a unified API and factories for dealing with archives + in different
svn commit: r759143 [1/2] - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
Author: bodewig Date: Fri Mar 27 14:14:07 2009 New Revision: 759143 URL: http://svn.apache.org/viewvc?rev=759143&view=rev Log: Improve bzip2 creation speed, submitted by Rodrigo Schmidt to Ant, COMPRESS-58 Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
svn commit: r759045 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/optimization/linear/SimplexTableau.java test/org/apache/commons/math/optimization/linear/SimplexSolverTest.java
Author: luc Date: Fri Mar 27 07:56:04 2009 New Revision: 759045 URL: http://svn.apache.org/viewvc?rev=759045&view=rev Log: fixed an error in Simplex algorithm when several ambiguous solutions exist Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/linear/SimplexSolverTest.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java?rev=759045&r1=759044&r2=759045&view=diff == --- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java Fri Mar 27 07:56:04 2009 @@ -327,9 +327,20 @@ * @return The value of the given decision variable. */ protected double getDecisionVariableValue(final int decisionVariable) { -Integer basicRow = getBasicRow(getNumObjectiveFunctions() + decisionVariable); -return basicRow == null ? 0 : getEntry(basicRow, getRhsOffset()); -} + int col = getNumObjectiveFunctions() + decisionVariable; + Integer basicRow = getBasicRow(col); + if (basicRow == null) { + return 0; + } + // if there are multiple variables that can take the value on the RHS + // then we'll give the first variable that value + for (int i = getNumObjectiveFunctions(); i < col; i++) { + if (tableau.getEntry(basicRow, i) == 1) { + return 0; + } + } + return getEntry(basicRow, getRhsOffset()); + } /** * Subtracts a multiple of one row from another. Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/linear/SimplexSolverTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/linear/SimplexSolverTest.java?rev=759045&r1=759044&r2=759045&view=diff == --- commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/linear/SimplexSolverTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/linear/SimplexSolverTest.java Fri Mar 27 07:56:04 2009 @@ -143,7 +143,7 @@ assertEquals(1438556.7491409, solution.getValue(), .001); } -public void testSomething() throws OptimizationException { +public void testTrivialModel() throws OptimizationException { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 1 }, 0); Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.EQ, 0)); @@ -276,8 +276,7 @@ SimplexSolver solver = new SimplexSolver(); RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MINIMIZE, true); -assertEquals(13366.0, solution.getValue(), .001); -//assertEquals(7518.0, solution.getValue(), .001); +assertEquals(7518.0, solution.getValue(), .001); } /**
svn commit: r759037 - /commons/proper/exec/trunk/src/site/xdoc/testmatrix.xml
Author: joehni Date: Fri Mar 27 07:06:08 2009 New Revision: 759037 URL: http://svn.apache.org/viewvc?rev=759037&view=rev Log: Correct test platform. Modified: commons/proper/exec/trunk/src/site/xdoc/testmatrix.xml Modified: commons/proper/exec/trunk/src/site/xdoc/testmatrix.xml URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/site/xdoc/testmatrix.xml?rev=759037&r1=759036&r2=759037&view=diff == --- commons/proper/exec/trunk/src/site/xdoc/testmatrix.xml (original) +++ commons/proper/exec/trunk/src/site/xdoc/testmatrix.xml Fri Mar 27 07:06:08 2009 @@ -67,25 +67,25 @@ Joerg Schaible - Linux (2.6.22, x86, 32 bit) + Linux (2.6.27, x86, 32 bit) IBM JDK 1.6.0.3 Passed Joerg Schaible - Linux (2.6.22, x86, 32 bit) + Linux (2.6.27, x86, 32 bit) IcedTea6-bin 1.4 Passed Joerg Schaible - Linux (2.6.22, x86, 32 bit) + Linux (2.6.27, x86, 32 bit) WebLogic JRockit 1.4.2.16 Passed Joerg Schaible - Linux (2.6.22, x86, 32 bit) + Linux (2.6.27, x86, 32 bit) WebLogic JRockit 1.5.0.14 Passed Joerg Schaible