synchronized getNewMirrorOnError() for safe writing of numTries

`volatile` allows for safe multi-threaded reading, `synchronized` allows
for safe multi-threaded writing.
This commit is contained in:
Hans-Christoph Steiner 2021-04-06 20:53:53 +02:00
parent 1758c2c9f1
commit f39fc1386a

View File

@ -267,7 +267,7 @@ public class FDroidApp extends Application implements androidx.work.Configuratio
* @see #getTimeout() * @see #getTimeout()
* @see Repo#getRandomMirror(String) * @see Repo#getRandomMirror(String)
*/ */
public static String getNewMirrorOnError(@Nullable String urlString, Repo repo2) throws IOException { public static synchronized String getNewMirrorOnError(@Nullable String urlString, Repo repo2) throws IOException {
if (repo2.hasMirrors()) { if (repo2.hasMirrors()) {
if (numTries <= 0) { if (numTries <= 0) {
if (timeout == Downloader.DEFAULT_TIMEOUT) { if (timeout == Downloader.DEFAULT_TIMEOUT) {