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()`.
This commit is contained in:
Rory Hunter 2020-10-30 11:57:18 +00:00 committed by GitHub
parent 0e81fc641a
commit f6692ec749
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -267,9 +267,12 @@ public class QuotaAwareFileSystemProviderTests extends LuceneTestCase {
FileSystemProvider systemProvider = quotaFile.getFileSystem().provider(); FileSystemProvider systemProvider = quotaFile.getFileSystem().provider();
DelegatingProvider cyclicProvider = new DelegatingProvider(systemProvider) { DelegatingProvider cyclicProvider = new DelegatingProvider(systemProvider) {
@Override @Override
@SuppressForbidden(reason = "Uses new File() to work around test issue on Windows")
public Path getPath(URI uri) { public Path getPath(URI uri) {
try { 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) { } catch (URISyntaxException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }