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
@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 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, public ProjectGenerationInvoker(ApplicationContext parentApplicationContext,
ProjectRequestToDescriptionConverter<R> requestConverter) { ProjectRequestToDescriptionConverter<R> requestConverter) {
@@ -144,10 +144,7 @@ public class ProjectGenerationInvoker<R extends ProjectRequest> {
private void addTempFile(Path group, Path file) { private void addTempFile(Path group, Path file) {
this.temporaryFiles.compute(group, (path, paths) -> { this.temporaryFiles.compute(group, (path, paths) -> {
List<Path> newPaths = paths; List<Path> newPaths = (paths != null) ? paths : new ArrayList<>();
if (newPaths == null) {
newPaths = new ArrayList<>();
}
newPaths.add(file); newPaths.add(file);
return newPaths; return newPaths;
}); });