Skip to content

Commit 2ab0647

Browse files
committed
Use pid and timestamp to generate tmp file name
1 parent bc7f9af commit 2ab0647

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

common/utils/src/main/java/org/graalvm/buildtools/agent/AgentConfiguration.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,10 @@ private void addDefaultAccessFilter() {
163163
logger.info("Ignore directory creation because " + agentDir + " directory is already created.");
164164
}
165165

166-
Path tmpAccessFilter = null;
167-
try {
168-
tmpAccessFilter = Files.createTempFile(agentDir, ACCESS_FILTER_PREFIX, ACCESS_FILTER_SUFFIX);
169-
Files.copy(accessFilterData, tmpAccessFilter);
170-
} catch (FileAlreadyExistsException e) {
171-
logger.info("Temporary access-filter file already exists and we should just rename it.");
172-
}
173-
174-
if (tmpAccessFilter == null) {
175-
throw new IOException("Cannot create temporary access-filter file.");
176-
}
166+
long pid = ProcessHandle.current().pid();
167+
long time = System.currentTimeMillis();
168+
Path tmpAccessFilter = agentDir.resolve(ACCESS_FILTER_PREFIX + pid + time + ACCESS_FILTER_SUFFIX);
169+
Files.copy(accessFilterData, tmpAccessFilter);
177170

178171
try {
179172
Files.move(tmpAccessFilter, accessFilterFile, StandardCopyOption.ATOMIC_MOVE);

0 commit comments

Comments
 (0)