Skip to content

Commit

Permalink
Use thread-safe structures in FetchingService
Browse files Browse the repository at this point in the history
Because in theory they could be used from multiple threads in parallel.
  • Loading branch information
yrodiere committed Jan 11, 2024
1 parent 5ef67df commit fddfc2e
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import jakarta.annotation.PreDestroy;
Expand All @@ -30,6 +29,8 @@
import org.hibernate.search.util.common.impl.Closer;
import org.hibernate.search.util.common.impl.SuppressingCloser;

import io.vertx.core.impl.ConcurrentHashSet;

@ApplicationScoped
public class FetchingService {

Expand All @@ -39,8 +40,8 @@ public class FetchingService {
@Inject
QuarkusIOConfig quarkusIOConfig;

private final Map<URI, GitCloneDirectory.Details> detailsCache = new HashMap<>();
private final Set<CloseableDirectory> tempDirectories = new HashSet<>();
private final Map<URI, GitCloneDirectory.Details> detailsCache = new ConcurrentHashMap<>();
private final Set<CloseableDirectory> tempDirectories = new ConcurrentHashSet<>();

public QuarkusIO fetchQuarkusIo() {
CompletableFuture<GitCloneDirectory> main = null;
Expand Down

0 comments on commit fddfc2e

Please sign in to comment.