소스 검색

Fix a quota-aware-fs test on Windows (#64401)

One of the `quota-aware-fs` plugin's tests was failing on Windows, due to a path being
constructed like `/C:/...`. Work around this using `new File()`.
Rory Hunter 5 년 전
부모
커밋
f6692ec749
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      plugins/quota-aware-fs/src/test/java/org/elasticsearch/fs/quotaaware/QuotaAwareFileSystemProviderTests.java

+ 4 - 1
plugins/quota-aware-fs/src/test/java/org/elasticsearch/fs/quotaaware/QuotaAwareFileSystemProviderTests.java

@@ -267,9 +267,12 @@ public class QuotaAwareFileSystemProviderTests extends LuceneTestCase {
         FileSystemProvider systemProvider = quotaFile.getFileSystem().provider();
         DelegatingProvider cyclicProvider = new DelegatingProvider(systemProvider) {
             @Override
+            @SuppressForbidden(reason = "Uses new File() to work around test issue on Windows")
             public Path getPath(URI uri) {
                 try {
-                    return cyclicReference.getFileSystem(new URI("file:///")).getPath(uri.getPath());
+                    // This convoluted line is necessary in order to get a valid path on Windows.
+                    final String uriPath = new File(uri.getPath()).toPath().toString();
+                    return cyclicReference.getFileSystem(new URI("file:///")).getPath(uriPath);
                 } catch (URISyntaxException e) {
                     throw new RuntimeException(e);
                 }