Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ private void createTempDir(Path tempDir) {
// we will find the first offender not having the expected permissions and fail the check
if (isPosixFs) {
// take the first subfolder below the base temp dir
Path root = baseTempDir.resolve(baseTempDir.relativize(tempDir).getRoot());
// we can wave the checks for tempDir being a subdir of baseTempDir because that's how it is
// created
Path root = baseTempDir.resolve(baseTempDir.relativize(tempDir).getName(0));
try {
AtomicReference<Path> failed = new AtomicReference<>();
Files.walkFileTree(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.UUID;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.LockSupport;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -80,8 +79,7 @@ void testFromConfigNotWritable() throws Exception {
Properties props = new Properties();
props.put(ProfilingConfig.PROFILING_TEMP_DIR, myDir.toString());
ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props);
TempLocationManager tempLocationManager = new TempLocationManager(configProvider);
assertThrows(IllegalStateException.class, tempLocationManager::getTempDir);
assertThrows(IllegalStateException.class, () -> new TempLocationManager(configProvider));
}

@ParameterizedTest
Expand Down Expand Up @@ -246,29 +244,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
assertEquals(shouldSucceed, rslt);
}

@Test
void testShortCircuit() throws Exception {
Path baseDir =
Files.createTempDirectory(
"ddprof-test-",
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------")));
AtomicBoolean executed = new AtomicBoolean();
TempLocationManager.CleanupHook hook =
new TempLocationManager.CleanupHook() {
@Override
public void onCleanupStart(boolean selfCleanup, long timeout, TimeUnit unit) {
executed.set(true);
}
};
TempLocationManager instance = instance(baseDir, false, hook);

instance.createDirStructure();

boolean ret = instance.cleanup(false);
assertTrue(ret);
assertFalse(executed.get());
}

private static Stream<Arguments> timeoutTestArguments() {
List<Arguments> argumentsList = new ArrayList<>();
for (boolean selfCleanup : new boolean[] {true, false}) {
Expand Down