Skip to content

Commit

Permalink
Merge pull request #127 from Suwayomi/j21-executor-fix
Browse files Browse the repository at this point in the history
Use try-with-resources for executorService
  • Loading branch information
aless2003 authored Jun 13, 2024
2 parents 06aec98 + 8e3e4d0 commit 1392d00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/main/frontend/themes/miku/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import "theme-editor.css";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ private Div createSearchResultDiv(Source source, List<Manga> mangaList) {
return searchResult;
}

/**
* Searches for manga in the specified sources
*
* @param query the search query
* @param langGroupedSources the sources grouped by language
*/
private void searchSources(String query, Map<String, List<Source>> langGroupedSources) {
for (var langSet : langGroupedSources.entrySet()) {

Expand All @@ -348,9 +354,7 @@ private void searchSources(String query, Map<String, List<Source>> langGroupedSo
searchTasks.add(runnable);
}

// When upgrading to Java 21 put the executor in a try-with-resources block instead
var executor = Executors.newCachedThreadPool();
try {
try (var executor = Executors.newCachedThreadPool()) {
executor.invokeAll(searchTasks);
executor.shutdown();
} catch (InterruptedException e) {
Expand Down

0 comments on commit 1392d00

Please sign in to comment.