|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
[jira] Created: (VFS-218) .skip() always returns the same number as given as parameter while the stream itself may or may not skip to given position.skip() always returns the same number as given as parameter while the stream itself may or may not skip to given position
-------------------------------------------------------------------------------------------------------------------------- Key: VFS-218 URL: https://issues.apache.org/jira/browse/VFS-218 Project: Commons VFS Issue Type: Bug Affects Versions: 1.0 Environment: Java 5, using jdk1.6.0_06 on Windows XP SP3 Reporter: Not Telling The code below should reproduce the bug, so far I've tested this with file: and res: file systems and at least those two expose this bug. As you may notice from the source, you should have file called "bla.txt" containing "blabla" (6 characters) in your C:\temp\ folder for this. {code:title=VFSStreamSkipping.java} import java.io.IOException; import java.io.InputStream; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileSystemManager; import org.apache.commons.vfs.VFS; /** * This class demonstrates buggy behaviour of .skip() when using VFS. * The bug is that no matter how many bytes were actually skipped, .skip() * always returns the same number as the user tried to skip. The stream itself * may get skipped though, if one tries to read the stream in this example * after .skip(), it will return -1 indicating that .skip() was executed * properly. */ public class VFSStreamSkipping { public static void main(String[] args) { FileObject file; FileSystemManager fsm; try { fsm = VFS.getManager(); } catch (FileSystemException e) { fsm = null; } InputStream is = null; try { file = fsm.resolveFile("file:C:/temp/bla.txt"); // file content is simply "blabla" with no \n or \r is = file.getContent().getInputStream(); } catch (FileSystemException e) {} try { long skipped = is.skip(9L); System.out.println(skipped+" <= prints 9, this should be 6 as per javadoc's specification; "+ "http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html#skip(long)"); System.out.println(is.read()); } catch (IOException e) {} } } {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Resolved: (VFS-218) .skip() always returns the same number as given as parameter while the stream itself may or may not skip to given position[ https://issues.apache.org/jira/browse/VFS-218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mario Ivankovits resolved VFS-218. ---------------------------------- Resolution: Invalid Hi! ... and so does this code snippet {code} FileInputStream fis = new FileInputStream("C:/temp/bla.txt"); long skipped = fis.skip(9L); System.out.println(skipped+" <= prints 9, this should be 6 as per javadoc's specification; "+ "http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html#skip(long)"); {code} And this is due to a bug/feature in java [1] which has already been added to the documentation of FileInputStream [2]. Clearly, FileInputStream breaks the contract of its interface. Seems like you are out of luck. Ciao, Mario [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6294974 [2] http://java.sun.com/javase/6/docs/api/java/io/FileInputStream.html > .skip() always returns the same number as given as parameter while the stream itself may or may not skip to given position > -------------------------------------------------------------------------------------------------------------------------- > > Key: VFS-218 > URL: https://issues.apache.org/jira/browse/VFS-218 > Project: Commons VFS > Issue Type: Bug > Affects Versions: 1.0 > Environment: Java 5, using jdk1.6.0_06 on Windows XP SP3 > Reporter: Not Telling > > The code below should reproduce the bug, so far I've tested this with file: and res: file systems and at least those two expose this bug. As you may notice from the source, you should have file called "bla.txt" containing "blabla" (6 characters) in your C:\temp\ folder for this. > {code:title=VFSStreamSkipping.java} > import java.io.IOException; > import java.io.InputStream; > import org.apache.commons.vfs.FileObject; > import org.apache.commons.vfs.FileSystemException; > import org.apache.commons.vfs.FileSystemManager; > import org.apache.commons.vfs.VFS; > /** > * This class demonstrates buggy behaviour of .skip() when using VFS. > * The bug is that no matter how many bytes were actually skipped, .skip() > * always returns the same number as the user tried to skip. The stream itself > * may get skipped though, if one tries to read the stream in this example > * after .skip(), it will return -1 indicating that .skip() was executed > * properly. > */ > public class VFSStreamSkipping { > > public static void main(String[] args) { > FileObject file; > FileSystemManager fsm; > try { > fsm = VFS.getManager(); > } catch (FileSystemException e) { > fsm = null; > } > > InputStream is = null; > > try { > file = fsm.resolveFile("file:C:/temp/bla.txt"); > // file content is simply "blabla" with no \n or \r > is = file.getContent().getInputStream(); > } catch (FileSystemException e) {} > > try { > long skipped = is.skip(9L); > System.out.println(skipped+" <= prints 9, this should be 6 as per javadoc's specification; "+ > "http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html#skip(long)"); > > System.out.println(is.read()); > } catch (IOException e) {} > } > } > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
| Free Forum Powered by Nabble | Forum Help |