Skip to content

Commit ac59dd8

Browse files
authored
Fix bug in FileHandler: it always failed on MacOS (#16771)
The `alternatives` list is immutable, so trying to add `"mac/" + name` to it always failed. P.S. I suspect this class is not used anymore, and should be removed.
1 parent f51e386 commit ac59dd8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

java/src/org/openqa/selenium/io/FileHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717

1818
package org.openqa.selenium.io;
1919

20+
import static java.util.Locale.ROOT;
21+
import static java.util.Objects.requireNonNull;
22+
2023
import java.io.File;
2124
import java.io.FileOutputStream;
2225
import java.io.IOException;
2326
import java.io.InputStream;
2427
import java.io.OutputStream;
2528
import java.nio.file.Files;
26-
import java.util.Arrays;
27-
import java.util.List;
28-
import java.util.Locale;
29-
import java.util.Objects;
29+
import java.util.*;
3030

3131
/** Utility methods for common filesystem activities */
3232
public class FileHandler {
@@ -42,10 +42,10 @@ public static void copyResource(File outputDir, Class<?> forClassLoader, String.
4242

4343
private static InputStream locateResource(Class<?> forClassLoader, String name)
4444
throws IOException {
45-
String arch =
46-
Objects.requireNonNull(System.getProperty("os.arch")).toLowerCase(Locale.ENGLISH) + "/";
47-
List<String> alternatives = Arrays.asList(name, "/" + name, arch + name, "/" + arch + name);
48-
if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac")) {
45+
String arch = requireNonNull(System.getProperty("os.arch")).toLowerCase(ROOT) + "/";
46+
List<String> alternatives =
47+
new ArrayList<>(List.of(name, "/" + name, arch + name, "/" + arch + name));
48+
if (System.getProperty("os.name").toLowerCase(ROOT).contains("mac")) {
4949
alternatives.add("mac/" + name);
5050
alternatives.add("/mac/" + name);
5151
}

0 commit comments

Comments
 (0)