[
https://issues.apache.org/jira/browse/ZOOKEEPER-2284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14935623#comment-14935623
]
Chris Nauroth commented on ZOOKEEPER-2284:
------------------------------------------
{quote}
On windows, I find no way to create a file which even does not have read
permission.
So if I write test case as you suggested it would fail on windows.
{quote}
Yes, this is a persistent problem for tests in the Hadoop codebase too. We
have tests that try to simulate broken data directories by restricting
permissions, but Windows has logic that the owner/creator of the file/directory
always has access, regardless of the NTFS ACL entries present on the file.
I've searched many times for a solution, but I've never found a good way to get
these kinds of tests to work correctly on Windows.
In Hadoop, we still write these kinds of tests, but we use JUnit's
{{assumeTrue}} to skip the tests on Windows. That way, at least we get the
coverage on Linux. It looks like we could do something similar here with
{{assumeTrue(!org.apache.zookeeper.Shell.WINDOWS);}}.
> LogFormatter and SnapshotFormatter does not handle FileNotFoundException
> gracefully
> -----------------------------------------------------------------------------------
>
> Key: ZOOKEEPER-2284
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2284
> Project: ZooKeeper
> Issue Type: Bug
> Affects Versions: 3.5.0
> Reporter: Arshad Mohammad
> Assignee: Arshad Mohammad
> Priority: Minor
> Fix For: 3.5.2
>
> Attachments: ZOOKEEPER-2284-01.patch, ZOOKEEPER-2284-02.patch,
> ZOOKEEPER-2284-03.patch
>
>
> {{LogFormatter}} and {{SnapshotFormatter}} does not handle
> FileNotFoundException gracefully. If file no exist then these classes
> propagate the exception to console.
> {code}
> Exception in thread "main" java.io.FileNotFoundException: log.1 (The system
> cannot find the file specified)
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(FileInputStream.java:146)
> at java.io.FileInputStream.<init>(FileInputStream.java:101)
> at org.apache.zookeeper.server.LogFormatter.main(LogFormatter.java:49)
> {code}
> File existence should be validated and appropriate message should be
> displayed on console if file does not exist
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)