Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 33329 invoked from network); 26 May 2006 14:26:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 May 2006 14:26:58 -0000 Received: (qmail 35215 invoked by uid 500); 26 May 2006 14:26:57 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 35172 invoked by uid 500); 26 May 2006 14:26:57 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 35159 invoked by uid 99); 26 May 2006 14:26:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 May 2006 07:26:57 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 May 2006 07:26:56 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B9F471A983A; Fri, 26 May 2006 07:26:36 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r409677 - in /incubator/harmony/enhanced/classlib/trunk/modules: luni/src/test/java/tests/api/java/io/ nio/src/main/java/org/apache/harmony/nio/internal/ nio/src/test/java/org/apache/harmony/tests/java/nio/channels/ Date: Fri, 26 May 2006 14:26:34 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060526142636.B9F471A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: tellison Date: Fri May 26 07:26:33 2006 New Revision: 409677 URL: http://svn.apache.org/viewvc?rev=409677&view=rev Log: Apply patch HARMONY-508 ([classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform) Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java?rev=409677&r1=409676&r2=409677&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java Fri May 26 07:26:33 2006 @@ -208,6 +208,25 @@ } /** + * @tests java.io.FileOutputStream#getChannel() + */ + public void test_getChannel() throws Exception { + // Regression for HARMONY- + File tmpfile = File.createTempFile("FileOutputStream", "tmp"); + tmpfile.deleteOnExit(); + FileOutputStream fos = new FileOutputStream(tmpfile); + byte[] b = new byte[10]; + for (int i = 10; i < b.length; i++) { + b[i] = (byte) i; + } + fos.write(b); + fos.flush(); + fos.close(); + FileOutputStream f = new FileOutputStream(tmpfile, true); + assertEquals(f.getChannel().position(), 10); + } + + /** * Tears down the fixture, for example, close a network connection. This * method is called after a test is executed. */ Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java?rev=409677&r1=409676&r2=409677&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java Fri May 26 07:26:33 2006 @@ -34,6 +34,14 @@ super(stream, handle); append = isAppend; } + + /* + * (non-Javadoc) + * @see org.apache.harmony.nio.internal.FileChannelImpl#position() + */ + public long position() throws IOException { + return append ? size() : super.position(); + } public long transferTo(long position, long count, WritableByteChannel target) throws IOException { Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java?rev=409677&r1=409676&r2=409677&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java Fri May 26 07:26:33 2006 @@ -36,4 +36,23 @@ out.close(); assertFalse("Assert 0: Channel is still open", channel.isOpen()); } + + /** + * @tests java.nio.channels.FileChannel#position() + */ + public void test_Position() throws Exception { + // Regression test for Harmony-508 + File tmpfile = File.createTempFile("FileOutputStream", "tmp"); + tmpfile.deleteOnExit(); + FileOutputStream fos = new FileOutputStream(tmpfile); + byte[] b = new byte[10]; + for (int i = 0; i < b.length; i++) { + b[i] = (byte) i; + } + fos.write(b); + fos.flush(); + fos.close(); + FileOutputStream f = new FileOutputStream(tmpfile, true); + assertEquals(10, f.getChannel().position()); + } }