[ 
https://issues.apache.org/jira/browse/GEODE-9526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17402365#comment-17402365
 ] 

ASF subversion and git services commented on GEODE-9526:
--------------------------------------------------------

Commit 0d1954bbabccf7cc466392c48ecfd82df664b1b9 in geode's branch 
refs/heads/develop from Dale Emery
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=0d1954b ]

GEODE-9526: Fix path computation in DiskStore test (#6777)

PROBLEM

`DiskStoreCommandsDUnitTest.verifyDiskStoreInServer(...)` incorrectly
assumes thatif a file path does not start with a file separator, it must
be relative. It attempts to convert such a path to absolute by
prepending the current directory onto it:

```
String absoluteDiskDirectoryName = diskDirectoryName.startsWith(File.separator)
        ? diskDirectoryName
        : CURRENT_DIRECTORY + File.separator + diskDirectoryName;
```

On Windows, an absolute file path can begin with a letter, e.g.
`C:\Users\geode\AppData\Local\Temp\junit783716437098694709\DISKSTORE`.
The test incorrectly interprets a path like this as relative, and
prepends the current directory onto it, producing an invalid path. It
then uses this incorrect path in an assertion, causing the test to fail
when it should pass.

SOLUTION

Use Java's `Path` implementation for the OS to compute the absolute form of the 
given file path.

> DiskStore test incorrectly treats absolute path as relative on Windows
> ----------------------------------------------------------------------
>
>                 Key: GEODE-9526
>                 URL: https://issues.apache.org/jira/browse/GEODE-9526
>             Project: Geode
>          Issue Type: Test
>          Components: tests
>            Reporter: Dale Emery
>            Assignee: Dale Emery
>            Priority: Major
>              Labels: GeodeOperationAPI, pull-request-available
>             Fix For: 1.15.0
>
>
> On Windows, an absolute file path can begin with a letter (e.g. "C:\…"). 
> {{DiskStoreCommandsDUnitTest.verifyDiskStoreInServer(...)}} incorrectly 
> assumes that, because such a path does not start with a file separator, it 
> must be relative. It then attempts to convert it to an absolute path by 
> prepending the current directory onto it:
> {noformat}
> String absoluteDiskDirectoryName = 
> diskDirectoryName.startsWith(File.separator)
>         ? diskDirectoryName
>         : CURRENT_DIRECTORY + File.separator + diskDirectoryName;
> {noformat}
> On Windows, the resulting file path is unusable.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to