Skip to content

Commit

Permalink
Merge pull request #229 from sopra-fs24-group-09/Increase_thread_10
Browse files Browse the repository at this point in the history
Increase thread 10
  • Loading branch information
zihanltesla authored May 20, 2024
2 parents d2f43d7 + e75540c commit c99f014
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ch/uzh/ifi/hase/soprafs24/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void addCorsMappings(@SuppressWarnings("null") CorsRegistry registry) {
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setCorePoolSize(10);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(25);
executor.setThreadNamePrefix("Async-");
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/ch/uzh/ifi/hase/soprafs24/service/RoomService.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,18 @@ public Room createRoom(Room newRoom) {
// Async fetch words for the theme while creating the room
CompletableFuture<List<String>> wordsFuture = CompletableFuture.supplyAsync(() -> {
try {
return getWords(theme);
List<String> words;
int retryCount = 0;
while (true) {
words = getWords(theme);
if(words != null){
return words;
}
retryCount++;
if (retryCount >= 3) {
return new ArrayList<>(Arrays.asList("sopra", "group", "milestone", "sprint", "task", "client", "server"));
}
}
} catch (IOException e) {
System.err.println("Error while getting words: " + e.getMessage());
throw new RuntimeException(e);
Expand Down Expand Up @@ -208,7 +219,7 @@ public List<String> getWords(String theme) throws IOException {
throw new IOException("Failed to extract JSON from message content");
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
throw new IOException("Failed to parse JSON response", e);
}
} else {
Expand Down

0 comments on commit c99f014

Please sign in to comment.