Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/main/java/hudson/remoting/JarLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collections;
Expand All @@ -25,15 +26,12 @@

private static final Logger LOGGER = Logger.getLogger(JarLoaderImpl.class.getName());

@SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "TODO needs triage")
private final ConcurrentMap<Checksum, URL> knownJars = new ConcurrentHashMap<>();
private static final ConcurrentMap<Checksum, URL> KNOWN_JARS = new ConcurrentHashMap<>();

@SuppressFBWarnings(
value = {"DMI_COLLECTION_OF_URLS", "SE_BAD_FIELD"},
justification = "TODO needs triage")
private final ConcurrentMap<URL, Checksum> checksums = new ConcurrentHashMap<>();
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "TODO needs triage")

Check warning on line 31 in src/main/java/hudson/remoting/JarLoaderImpl.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: needs triage")
private static final ConcurrentMap<URL, Checksum> CHECKSUMS = new ConcurrentHashMap<>();

@SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "TODO needs triage")

Check warning on line 34 in src/main/java/hudson/remoting/JarLoaderImpl.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: needs triage")
private final Set<Checksum> presentOnRemote = Collections.synchronizedSet(new HashSet<>());

@Override
Expand All @@ -42,7 +40,7 @@
justification = "This is only used for managing the jar cache as files, not URLs.")
public void writeJarTo(long sum1, long sum2, OutputStream sink) throws IOException, InterruptedException {
Checksum k = new Checksum(sum1, sum2);
URL url = knownJars.get(k);
URL url = KNOWN_JARS.get(k);
if (url == null) {
throw new IOException("Unadvertised jar file " + k);
}
Expand Down Expand Up @@ -93,16 +91,19 @@
* Obtains the checksum for the jar at the specified URL.
*/
public Checksum calcChecksum(URL jar) throws IOException {
Checksum v = checksums.get(jar); // cache hit
if (v != null) {
return v;
try {
return CHECKSUMS.computeIfAbsent(jar, u -> {
try {
Checksum c = Checksum.forURL(u);
KNOWN_JARS.put(c, u);
return c;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
} catch (UncheckedIOException e) {
throw e.getCause();
}

v = Checksum.forURL(jar);

knownJars.put(v, jar);
checksums.put(jar, v);
return v;
}

/**
Expand Down
Loading