Deprecate Files.createTempDir(), noting that better alternatives exis… · google/guava@fec0dbc (original) (raw)
File tree
- android/guava/src/com/google/common/io
- guava/src/com/google/common/io
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -398,6 +398,11 @@ public static boolean equal(File file1, File file2) throws IOException { | ||
| 398 | 398 | * be exploited to create security vulnerabilities, especially when executable files are to be |
| 399 | 399 | * written into the directory. |
| 400 | 400 | * |
| 401 | + * Depending on the environmment that this code is run in, the system temporary directory (and |
|
| 402 | + * thus the directory this method creates) may be more visible that a program would like - files | |
| 403 | + * written to this directory may be read or overwritten by hostile programs running on the same | |
| 404 | + * machine. | |
| 405 | + * | |
| 401 | 406 | * This method assumes that the temporary volume is writable, has free inodes and free blocks, |
| 402 | 407 | * and that it will not be called thousands of times per second. |
| 403 | 408 | * |
| @@ -406,8 +411,15 @@ public static boolean equal(File file1, File file2) throws IOException { | ||
| 406 | 411 | * |
| 407 | 412 | * @return the newly-created directory |
| 408 | 413 | * @throws IllegalStateException if the directory could not be created |
| 414 | + * @deprecated For Android users, see the <a | |
| 415 | + * href="https://developer.android.com/training/data-storage" target="_blank">Data and File | |
| 416 | + * Storage overview to select an appropriate temporary directory (perhaps {@code | |
| 417 | + * context.getCacheDir()}). For developers on Java 7 or later, use {@link | |
| 418 | + * java.nio.file.Files#createTempDirectory}, transforming it to a {@link File} using {@link | |
| 419 | + * java.nio.file.Path#toFile() toFile()} if needed. | |
| 409 | 420 | */ |
| 410 | 421 | @Beta |
| 422 | +@Deprecated | |
| 411 | 423 | public static File createTempDir() { |
| 412 | 424 | File baseDir = new File(System.getProperty("java.io.tmpdir")); |
| 413 | 425 | @SuppressWarnings("GoodTime") // reading system time without TimeSource |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -398,6 +398,11 @@ public static boolean equal(File file1, File file2) throws IOException { | ||
| 398 | 398 | * be exploited to create security vulnerabilities, especially when executable files are to be |
| 399 | 399 | * written into the directory. |
| 400 | 400 | * |
| 401 | + * Depending on the environmment that this code is run in, the system temporary directory (and |
|
| 402 | + * thus the directory this method creates) may be more visible that a program would like - files | |
| 403 | + * written to this directory may be read or overwritten by hostile programs running on the same | |
| 404 | + * machine. | |
| 405 | + * | |
| 401 | 406 | * This method assumes that the temporary volume is writable, has free inodes and free blocks, |
| 402 | 407 | * and that it will not be called thousands of times per second. |
| 403 | 408 | * |
| @@ -406,8 +411,15 @@ public static boolean equal(File file1, File file2) throws IOException { | ||
| 406 | 411 | * |
| 407 | 412 | * @return the newly-created directory |
| 408 | 413 | * @throws IllegalStateException if the directory could not be created |
| 414 | + * @deprecated For Android users, see the <a | |
| 415 | + * href="https://developer.android.com/training/data-storage" target="_blank">Data and File | |
| 416 | + * Storage overview to select an appropriate temporary directory (perhaps {@code | |
| 417 | + * context.getCacheDir()}). For developers on Java 7 or later, use {@link | |
| 418 | + * java.nio.file.Files#createTempDirectory}, transforming it to a {@link File} using {@link | |
| 419 | + * java.nio.file.Path#toFile() toFile()} if needed. | |
| 409 | 420 | */ |
| 410 | 421 | @Beta |
| 422 | +@Deprecated | |
| 411 | 423 | public static File createTempDir() { |
| 412 | 424 | File baseDir = new File(System.getProperty("java.io.tmpdir")); |
| 413 | 425 | @SuppressWarnings("GoodTime") // reading system time without TimeSource |