From 97e451517626392f57abbd29569944202de0146b Mon Sep 17 00:00:00 2001 From: Clover Fox Date: Tue, 20 Aug 2019 20:51:36 +0100 Subject: [PATCH 1/2] added intellij project files to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a42f936..5cc72f4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ build/ dist/ target/ nbproject/ +.idea +*.iml nb-configuration.xml maven.properties github-user.properties \ No newline at end of file From cae3672dafc85c50babc6a7282de26d90c0a867f Mon Sep 17 00:00:00 2001 From: Clover Fox Date: Tue, 20 Aug 2019 20:57:41 +0100 Subject: [PATCH 2/2] For now we'll just catch the exception and continue on, if this fixes the problem we can look into a more elegant solution --- .../org/battlescribedata/dao/GitHubDao.java | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/battlescribedata/dao/GitHubDao.java b/src/main/java/org/battlescribedata/dao/GitHubDao.java index 0a7430c..76e3a16 100644 --- a/src/main/java/org/battlescribedata/dao/GitHubDao.java +++ b/src/main/java/org/battlescribedata/dao/GitHubDao.java @@ -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 future = executorService.submit(new Callable() { - - @Override - public Void call() throws IOException { - try { - refreshRepositories(); - } - catch (IOException e) { - logger.log( - Level.SEVERE, - "Failed to update repositories", - e); + Future 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() { + + @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); }