Skip to content

Commit b7e7d52

Browse files
authored
Fix #493: Use null to indicate no overriding file mode instead of -1 (#503)
Eliminate use of a `0` default parameter that was introduced by mistake
1 parent 18fa16a commit b7e7d52

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

core/src/main/java/org/testcontainers/images/builder/traits/FilesTrait.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface FilesTrait<SELF extends FilesTrait<SELF> & BuildContextBuilderT
1818
* @return self
1919
*/
2020
default SELF withFileFromFile(String path, File file) {
21-
return withFileFromPath(path, file.toPath(), 0);
21+
return withFileFromPath(path, file.toPath(), null);
2222
}
2323

2424
/**
@@ -28,7 +28,7 @@ default SELF withFileFromFile(String path, File file) {
2828
* @return self
2929
*/
3030
default SELF withFileFromPath(String path, Path filePath) {
31-
return withFileFromPath(path, filePath, 0);
31+
return withFileFromPath(path, filePath, null);
3232
}
3333

3434
/**
@@ -38,7 +38,7 @@ default SELF withFileFromPath(String path, Path filePath) {
3838
* @param mode octal value of posix file mode (000..777)
3939
* @return self
4040
*/
41-
default SELF withFileFromFile(String path, File file, int mode) {
41+
default SELF withFileFromFile(String path, File file, Integer mode) {
4242
return withFileFromPath(path, file.toPath(), mode);
4343
}
4444

@@ -49,7 +49,7 @@ default SELF withFileFromFile(String path, File file, int mode) {
4949
* @param mode octal value of posix file mode (000..777)
5050
* @return self
5151
*/
52-
default SELF withFileFromPath(String path, Path filePath, int mode) {
52+
default SELF withFileFromPath(String path, Path filePath, Integer mode) {
5353
final MountableFile mountableFile = MountableFile.forHostPath(filePath, mode);
5454
return ((SELF) this).withFileFromTransferable(path, mountableFile);
5555
}

core/src/main/java/org/testcontainers/utility/MountableFile.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class MountableFile implements Transferable {
4242
private static final int BASE_DIR_MODE = 0040000;
4343

4444
private final String path;
45-
private final int forcedFileMode;
45+
private final Integer forcedFileMode;
4646

4747
@Getter(lazy = true)
4848
private final String resolvedPath = resolvePath();
@@ -59,7 +59,7 @@ public class MountableFile implements Transferable {
5959
* @return a {@link MountableFile} that may be used to obtain a mountable path
6060
*/
6161
public static MountableFile forClasspathResource(@NotNull final String resourceName) {
62-
return forClasspathResource(resourceName, -1);
62+
return forClasspathResource(resourceName, null);
6363
}
6464

6565
/**
@@ -69,7 +69,7 @@ public static MountableFile forClasspathResource(@NotNull final String resourceN
6969
* @return a {@link MountableFile} that may be used to obtain a mountable path
7070
*/
7171
public static MountableFile forHostPath(@NotNull final String path) {
72-
return forHostPath(path, -1);
72+
return forHostPath(path, null);
7373
}
7474

7575
/**
@@ -79,7 +79,7 @@ public static MountableFile forHostPath(@NotNull final String path) {
7979
* @return a {@link MountableFile} that may be used to obtain a mountable path
8080
*/
8181
public static MountableFile forHostPath(final Path path) {
82-
return forHostPath(path, -1);
82+
return forHostPath(path, null);
8383
}
8484

8585
/**
@@ -89,7 +89,7 @@ public static MountableFile forHostPath(final Path path) {
8989
* @param mode octal value of posix file mode (000..777)
9090
* @return a {@link MountableFile} that may be used to obtain a mountable path
9191
*/
92-
public static MountableFile forClasspathResource(@NotNull final String resourceName, int mode) {
92+
public static MountableFile forClasspathResource(@NotNull final String resourceName, Integer mode) {
9393
return new MountableFile(getClasspathResource(resourceName, new HashSet<>()).toString(), mode);
9494
}
9595

@@ -100,7 +100,7 @@ public static MountableFile forClasspathResource(@NotNull final String resourceN
100100
* @param mode octal value of posix file mode (000..777)
101101
* @return a {@link MountableFile} that may be used to obtain a mountable path
102102
*/
103-
public static MountableFile forHostPath(@NotNull final String path, int mode) {
103+
public static MountableFile forHostPath(@NotNull final String path, Integer mode) {
104104
return new MountableFile(new File(path).toURI().toString(), mode);
105105
}
106106

@@ -111,7 +111,7 @@ public static MountableFile forHostPath(@NotNull final String path, int mode) {
111111
* @param mode octal value of posix file mode (000..777)
112112
* @return a {@link MountableFile} that may be used to obtain a mountable path
113113
*/
114-
public static MountableFile forHostPath(final Path path, int mode) {
114+
public static MountableFile forHostPath(final Path path, Integer mode) {
115115
return new MountableFile(path.toAbsolutePath().toString(), mode);
116116
}
117117

@@ -345,7 +345,7 @@ public int getFileMode() {
345345

346346
private int getUnixFileMode(final String pathAsString) {
347347
final Path path = Paths.get(pathAsString);
348-
if (this.forcedFileMode > -1) {
348+
if (this.forcedFileMode != null) {
349349
return this.getModeValue(path);
350350
}
351351

0 commit comments

Comments
 (0)