Skip to content

Commit

Permalink
[CELEBORN-1560] Remove usages of deprecated Files.createTempDir of Guava
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

### Why are the changes needed?

`com.google.common.io.Files#createTempDir` has been deprecated since long ago.
`java.nio.file.Files#createTempDirectory` should be used instead, as suggested in Guava's API Javadoc. (https://guava.dev/releases/33.1.0-jre/api/docs/com/google/common/io/Files.html)

### Does this PR introduce _any_ user-facing change?

### How was this patch tested?

Closes #2680 from bowenliang123/files-temp-dir.

Authored-by: Bowen Liang <[email protected]>
Signed-off-by: Shuang <[email protected]>
  • Loading branch information
bowenliang123 authored and RexXiong committed Aug 26, 2024
1 parent f226424 commit 4844c82
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.util.Random;

import com.google.common.io.Files;

import org.apache.celeborn.common.network.buffer.FileSegmentManagedBuffer;
import org.apache.celeborn.common.network.buffer.ManagedBuffer;
import org.apache.celeborn.common.network.buffer.NioManagedBuffer;
Expand All @@ -51,7 +50,7 @@ private static ByteBuffer createBuffer(int bufSize) {
}

StreamTestHelper() throws Exception {
tempDir = Files.createTempDir();
tempDir = Files.createTempDirectory(null).toFile();
emptyBuffer = createBuffer(0);
smallBuffer = createBuffer(100);
largeBuffer = createBuffer(100000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.celeborn.service.deploy.master

import com.google.common.io.Files
import java.nio.file.Files

import org.apache.celeborn.common.CelebornConf
import org.apache.celeborn.common.util.{CelebornExitKind, Utils}
Expand All @@ -30,7 +30,7 @@ class ApiMasterResourceAuthenticationSuite extends ApiBaseResourceAuthentication
override protected def httpService: HttpService = master

def getTmpDir(): String = {
val tmpDir = Files.createTempDir()
val tmpDir = Files.createTempDirectory(null).toFile
tmpDir.deleteOnExit()
tmpDir.getAbsolutePath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

package org.apache.celeborn.service.deploy.master

import com.google.common.io.Files
import java.nio.file.Files

import org.mockito.Mockito.{mock, times, verify}
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import org.scalatest.funsuite.AnyFunSuite
Expand All @@ -34,7 +35,7 @@ class MasterSuite extends AnyFunSuite
with Logging {

def getTmpDir(): String = {
val tmpDir = Files.createTempDir()
val tmpDir = Files.createTempDirectory(null).toFile
tmpDir.deleteOnExit()
tmpDir.getAbsolutePath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

package org.apache.celeborn.service.deploy.master.http.api

import java.nio.file.Files
import javax.ws.rs.client.Entity
import javax.ws.rs.core.{Form, MediaType}

import com.google.common.io.Files

import org.apache.celeborn.common.CelebornConf
import org.apache.celeborn.common.util.{CelebornExitKind, Utils}
import org.apache.celeborn.server.common.HttpService
Expand All @@ -34,7 +33,7 @@ class ApiMasterResourceSuite extends ApiBaseResourceSuite {
override protected def httpService: HttpService = master

def getTmpDir(): String = {
val tmpDir = Files.createTempDir()
val tmpDir = Files.createTempDirectory(null).toFile
tmpDir.deleteOnExit()
tmpDir.getAbsolutePath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

package org.apache.celeborn.service.deploy.master.http.api.v1

import java.nio.file.Files
import java.util.Collections
import javax.servlet.http.HttpServletResponse
import javax.ws.rs.client.Entity
import javax.ws.rs.core.MediaType

import com.google.common.io.Files

import org.apache.celeborn.common.CelebornConf
import org.apache.celeborn.common.util.{CelebornExitKind, Utils}
import org.apache.celeborn.rest.v1.model.{AppDiskUsageSnapshotsResponse, ApplicationsResponse, ExcludeWorkerRequest, HandleResponse, HostnamesResponse, RemoveWorkersUnavailableInfoRequest, SendWorkerEventRequest, ShufflesResponse, WorkerEventsResponse, WorkerId, WorkersResponse}
Expand All @@ -37,7 +36,7 @@ class ApiV1MasterResourceSuite extends ApiV1BaseResourceSuite {
override protected def httpService: HttpService = master

def getTmpDir(): String = {
val tmpDir = Files.createTempDir()
val tmpDir = Files.createTempDirectory(null).toFile
tmpDir.deleteOnExit()
tmpDir.getAbsolutePath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

import scala.Function0;
import scala.Tuple4;

import org.apache.hadoop.shaded.com.google.common.io.Files;
import org.mockito.Mockito;

import org.apache.celeborn.common.CelebornConf;
Expand Down Expand Up @@ -102,7 +102,7 @@ public static StorageManager prepareMemoryEvictEnvironment(
memoryFileInfo.replaceFileMeta(new MapFileMeta(32 * 1024, 10));
}

File tempDir = Files.createTempDir();
File tempDir = Files.createTempDirectory(null).toFile();
tempDir.deleteOnExit();
File file = getTemporaryFile(tempDir);
DiskFileInfo fileInfo = new DiskFileInfo(file, userIdentifier, celebornConf);
Expand Down

0 comments on commit 4844c82

Please sign in to comment.