Fix put to cache check

putIfAbsent should return null, whenever there was no value for the key
before it was put with the call. But however this does not seem to work
with the concurrent hash map (liskov?)
This commit is contained in:
René Pfeuffer
2020-04-26 18:11:08 +02:00
parent f6a19b2ed7
commit 0a87f4b872

View File

@@ -79,7 +79,8 @@ public class CachingAllWorkdirProvider implements CacheSupportingWorkdirProvider
@Override
public void contextClosed(CreateWorkdirContext<?, ?, ?> createWorkdirContext, File workdir) throws IOException {
String id = createWorkdirContext.getScmRepository().getId();
if (workdirs.putIfAbsent(id, workdir) != null) {
File putResult = workdirs.putIfAbsent(id, workdir);
if (putResult != null && putResult != workdir) {
deleteWorkdir(workdir);
}
}