You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Nikolay Bannikov (JIRA)" <ji...@apache.org> on 2006/05/25 13:46:29 UTC

[jira] Created: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

[classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
-----------------------------------------------------------------------------------------------------------

         Key: HARMONY-508
         URL: http://issues.apache.org/jira/browse/HARMONY-508
     Project: Harmony
        Type: Bug

  Components: Classlib  
    Reporter: Nikolay Bannikov
    Priority: Minor


According to  J2SE 1.5 specifications: 
The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 

import java.io.*; 
public class Test{ 
    public static void main(String[] args) { 
        FileOutputStream f = null; 
        try { 
	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(); 
	f = new FileOutputStream(tmpfile, true);
	System.out.println("position = "+f.getChannel().position()); 
        } catch (FileNotFoundException fnfe) { 
        } catch (IOException ioe) { 
        } catch (SecurityException se) { 
        } 
   } 
} 

Output on Harmony (Windows): 
position = 10

Output on Harmony (Linux): 
position = 0



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

Posted by "Nikolay Bannikov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-508?page=all ]

Nikolay Bannikov updated HARMONY-508:
-------------------------------------

    Attachment: FileOutputStreamTest.diffs

> [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
> -----------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-508
>          URL: http://issues.apache.org/jira/browse/HARMONY-508
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Nikolay Bannikov
>     Priority: Minor
>  Attachments: FileOutputStreamTest.diffs
>
> According to  J2SE 1.5 specifications: 
> The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 
> import java.io.*; 
> public class Test{ 
>     public static void main(String[] args) { 
>         FileOutputStream f = null; 
>         try { 
> 	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(); 
> 	f = new FileOutputStream(tmpfile, true);
> 	System.out.println("position = "+f.getChannel().position()); 
>         } catch (FileNotFoundException fnfe) { 
>         } catch (IOException ioe) { 
>         } catch (SecurityException se) { 
>         } 
>    } 
> } 
> Output on Harmony (Windows): 
> position = 10
> Output on Harmony (Linux): 
> position = 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-508?page=all ]
     
Tim Ellison resolved HARMONY-508:
---------------------------------

    Resolution: Fixed

Thanks Nikolay & Paulex,

Patch applied to LUNI tests and NIO impl and tests at repo revision r409677.

Please check that this fully resolves your problem.


> [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
> -----------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-508
>          URL: http://issues.apache.org/jira/browse/HARMONY-508
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Nikolay Bannikov
>     Assignee: Tim Ellison
>     Priority: Minor
>  Attachments: FileOutputStreamTest.diffs, harmony-508.diff
>
> According to  J2SE 1.5 specifications: 
> The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 
> import java.io.*; 
> public class Test{ 
>     public static void main(String[] args) { 
>         FileOutputStream f = null; 
>         try { 
> 	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(); 
> 	f = new FileOutputStream(tmpfile, true);
> 	System.out.println("position = "+f.getChannel().position()); 
>         } catch (FileNotFoundException fnfe) { 
>         } catch (IOException ioe) { 
>         } catch (SecurityException se) { 
>         } 
>    } 
> } 
> Output on Harmony (Windows): 
> position = 10
> Output on Harmony (Linux): 
> position = 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-508?page=comments#action_12413658 ] 

Paulex Yang commented on HARMONY-508:
-------------------------------------

Sorry I forgot another issue, I also suggets to mark this issue as "non-bug difference with RI" because RI fails on the test case.

> [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
> -----------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-508
>          URL: http://issues.apache.org/jira/browse/HARMONY-508
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Nikolay Bannikov
>     Assignee: Tim Ellison
>     Priority: Minor
>  Attachments: FileOutputStreamTest.diffs, harmony-508.diff
>
> According to  J2SE 1.5 specifications: 
> The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 
> import java.io.*; 
> public class Test{ 
>     public static void main(String[] args) { 
>         FileOutputStream f = null; 
>         try { 
> 	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(); 
> 	f = new FileOutputStream(tmpfile, true);
> 	System.out.println("position = "+f.getChannel().position()); 
>         } catch (FileNotFoundException fnfe) { 
>         } catch (IOException ioe) { 
>         } catch (SecurityException se) { 
>         } 
>    } 
> } 
> Output on Harmony (Windows): 
> position = 10
> Output on Harmony (Linux): 
> position = 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-508?page=all ]

Tim Ellison reassigned HARMONY-508:
-----------------------------------

    Assign To: Tim Ellison

> [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
> -----------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-508
>          URL: http://issues.apache.org/jira/browse/HARMONY-508
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Nikolay Bannikov
>     Assignee: Tim Ellison
>     Priority: Minor
>  Attachments: FileOutputStreamTest.diffs, harmony-508.diff
>
> According to  J2SE 1.5 specifications: 
> The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 
> import java.io.*; 
> public class Test{ 
>     public static void main(String[] args) { 
>         FileOutputStream f = null; 
>         try { 
> 	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(); 
> 	f = new FileOutputStream(tmpfile, true);
> 	System.out.println("position = "+f.getChannel().position()); 
>         } catch (FileNotFoundException fnfe) { 
>         } catch (IOException ioe) { 
>         } catch (SecurityException se) { 
>         } 
>    } 
> } 
> Output on Harmony (Windows): 
> position = 10
> Output on Harmony (Linux): 
> position = 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-508?page=all ]

Paulex Yang updated HARMONY-508:
--------------------------------

    Attachment: harmony-508.diff

Please try this patch, thanks.

Please note that RI return 0 on both Windows and Linux, so that I suggest the mark this issue as "Non-bug difference with RI". 

And Nikolay, thank you for your test,  I merged your test case into FileChannelTest instead of FileOutputStreamTest because it is actually a bug of FileChannel,  and I did a little modification, I supposed the index 'i' in the loop should be inited by 0 instead of 10, otherwise the loop body won't be accessible at all, and we have got agreement in mailing list that the assertEquals() should be written as assertEquals(expected, tobetest).

> [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
> -----------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-508
>          URL: http://issues.apache.org/jira/browse/HARMONY-508
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Nikolay Bannikov
>     Priority: Minor
>  Attachments: FileOutputStreamTest.diffs, harmony-508.diff
>
> According to  J2SE 1.5 specifications: 
> The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 
> import java.io.*; 
> public class Test{ 
>     public static void main(String[] args) { 
>         FileOutputStream f = null; 
>         try { 
> 	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(); 
> 	f = new FileOutputStream(tmpfile, true);
> 	System.out.println("position = "+f.getChannel().position()); 
>         } catch (FileNotFoundException fnfe) { 
>         } catch (IOException ioe) { 
>         } catch (SecurityException se) { 
>         } 
>    } 
> } 
> Output on Harmony (Windows): 
> position = 10
> Output on Harmony (Linux): 
> position = 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-508) [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-508?page=comments#action_12413653 ] 

Paulex Yang commented on HARMONY-508:
-------------------------------------

Tim, thank you, the fix for NIO looks fine.  But I have concerns on the Nikolay's test patch for LUNI, as I mentioned in my last comment, would you please to consider it? thank you.

> [classlib][luni] java.io.FileOutputStream.getChannel().position() returns incorrect value on Linux platform
> -----------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-508
>          URL: http://issues.apache.org/jira/browse/HARMONY-508
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Nikolay Bannikov
>     Assignee: Tim Ellison
>     Priority: Minor
>  Attachments: FileOutputStreamTest.diffs, harmony-508.diff
>
> According to  J2SE 1.5 specifications: 
> The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. 
> import java.io.*; 
> public class Test{ 
>     public static void main(String[] args) { 
>         FileOutputStream f = null; 
>         try { 
> 	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(); 
> 	f = new FileOutputStream(tmpfile, true);
> 	System.out.println("position = "+f.getChannel().position()); 
>         } catch (FileNotFoundException fnfe) { 
>         } catch (IOException ioe) { 
>         } catch (SecurityException se) { 
>         } 
>    } 
> } 
> Output on Harmony (Windows): 
> position = 10
> Output on Harmony (Linux): 
> position = 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira