Skip to content

Commit

Permalink
Remove inappropriate usage of @async (#3096)
Browse files Browse the repository at this point in the history
* Remove inappropriate usage of @async

* Remove unneeded method
  • Loading branch information
Sheikah45 authored Dec 23, 2023
1 parent c63001d commit 6851480
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

Expand All @@ -36,13 +35,11 @@ public class FeaturedModService {
private final FeaturedModMapper featuredModMapper;
private final GameUpdater gameUpdater;

@Async
public CompletableFuture<Void> updateFeaturedMod(String featuredModName, Map<String, Integer> featuredModFileVersions,
Integer baseVersion, boolean forReplays) {
return gameUpdater.update(featuredModName, featuredModFileVersions, baseVersion, forReplays);
}

@Async
public CompletableFuture<Void> updateFeaturedModToLatest(String featuredModName, boolean forReplays) {
return updateFeaturedMod(featuredModName, null, null, forReplays);
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/faforever/client/game/GamePrefsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.IOException;
Expand Down Expand Up @@ -88,7 +87,6 @@ public void writeActiveModUIDs(Set<String> activeMods) throws IOException {
Files.writeString(preferencesFile, preferencesContent);
}

@Async
public CompletableFuture<Void> patchGamePrefsForMultiInstances() {
return CompletableFuture.runAsync(() -> {
String prefsContent = readPreferencesFile();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/faforever/client/map/MapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -511,7 +510,6 @@ public CompletableFuture<MapVersionBean> updateLatestVersionIfNecessary(MapVersi
});
}

@Async
public CompletableFuture<Integer> getFileSize(MapVersionBean mapVersion) {
return fileSizeReader.getFileSize(mapVersion.getDownloadUrl());
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/faforever/client/mod/ModService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple2;
Expand Down Expand Up @@ -353,7 +352,6 @@ public Image loadThumbnail(ModVersionBean modVersion) {
() -> themeService.getThemeImage(ThemeService.NO_IMAGE_AVAILABLE));
}

@Async
public CompletableFuture<Integer> getFileSize(ModVersionBean modVersion) {
return fileSizeReader.getFileSize(modVersion.getDownloadUrl());
}
Expand Down Expand Up @@ -394,7 +392,6 @@ public void destroy() {
Optional.ofNullable(directoryWatcherThread).ifPresent(Thread::interrupt);
}

@Async
public CompletableFuture<Collection<ModVersionBean>> updateAndActivateModVersions(
final Collection<ModVersionBean> selectedModVersions) {
if (!preferences.isMapAndModAutoUpdate()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.faforever.client.task.CompletableTask;
import com.faforever.client.update.ClientConfiguration.ReleaseInfo;
import com.faforever.client.util.FileSizeReader;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
Expand All @@ -35,11 +34,6 @@ public CheckForUpdateTask(I18n i18n, PreferencesService preferencesService, File
this.operatingSystem = operatingSystem;
}

@VisibleForTesting
int getFileSize(URL url) {
return fileSizeReader.getFileSize(url).join();
}

@Override
protected UpdateInfo call() throws Exception {
updateTitle(i18n.get("clientUpdateCheckTask.title"));
Expand All @@ -59,7 +53,7 @@ protected UpdateInfo call() throws Exception {
return null;
}

int fileSize = getFileSize(downloadUrl);
int fileSize = fileSizeReader.getFileSize(downloadUrl).join();

return new UpdateInfo(
version,
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/faforever/client/util/FileSizeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpMethod;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.IOException;
Expand All @@ -13,7 +12,7 @@
@Component
@Slf4j
public class FileSizeReader {
@Async

public CompletableFuture<Integer> getFileSize(URL url) {
return CompletableFuture.supplyAsync(() -> {
HttpURLConnection connection = null;
Expand Down

0 comments on commit 6851480

Please sign in to comment.