Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ build/
dist/
target/
nbproject/
.idea
*.iml
nb-configuration.xml
maven.properties
github-user.properties
53 changes: 35 additions & 18 deletions src/main/java/org/battlescribedata/dao/GitHubDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,27 +204,44 @@ private void refreshRepositoriesAsync() {
// We are currently updating the repos
return;
}

ThreadFactory threadFactory = com.google.appengine.api.ThreadManager.backgroundThreadFactory();
ExecutorService executorService = Executors.newSingleThreadExecutor(threadFactory);
Future<Void> future = executorService.submit(new Callable<Void>() {

@Override
public Void call() throws IOException {
try {
refreshRepositories();
}
catch (IOException e) {
logger.log(
Level.SEVERE,
"Failed to update repositories",
e);
Future<Void> future;
try {
/*
This line seems to be tha cause of Appspot failing to update some repos, we receive
"IllegalStateException "Limit on the number of active background threads was reached for this app version"
which seems to be because the timeout doesnt kill the thread, and since we have a max thread count of 10,
causes some problems. We can't just kill the Thread as we don't know the knock on effects that might have
For now we'll just catch the exception and continue on, if this fixes the problem we can look into a more
elegant solution
*/
future = executorService.submit(new Callable<Void>() {

@Override
public Void call() {
try {
refreshRepositories();
} catch (IOException e) {
logger.log(
Level.SEVERE,
"Failed to update repositories",
e);
}

return null;
}

return null;
}
});

});
} catch (Exception e) {
logger.log(
Level.WARNING,
"Problem submitting repository refresh task",
e);
// if we can't submit the task, there's no point on continuing
return;
}

try {
future.get(5, TimeUnit.MINUTES);
}
Expand Down