Polish "Fix thread-safety access in ProjectGenerationInvoker"

See gh-1125
This commit is contained in:
Stephane Nicoll
2020-09-12 07:08:54 +02:00
parent fd6bc357c2
commit dd6106371e

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class ProjectGenerationInvoker<R extends ProjectRequest> {
private final ProjectRequestToDescriptionConverter<R> requestConverter;
private transient Map<Path, List<Path>> temporaryFiles = new ConcurrentHashMap<>();
private final transient Map<Path, List<Path>> temporaryFiles = new ConcurrentHashMap<>();
public ProjectGenerationInvoker(ApplicationContext parentApplicationContext,
ProjectRequestToDescriptionConverter<R> requestConverter) {
@@ -144,10 +144,7 @@ public class ProjectGenerationInvoker<R extends ProjectRequest> {
private void addTempFile(Path group, Path file) {
this.temporaryFiles.compute(group, (path, paths) -> {
List<Path> newPaths = paths;
if (newPaths == null) {
newPaths = new ArrayList<>();
}
List<Path> newPaths = (paths != null) ? paths : new ArrayList<>();
newPaths.add(file);
return newPaths;
});