Skip to content

Commit ac22b14

Browse files
authored
Merge pull request commons-app#309 from misaochan/master
Add maximum timeout to await()
2 parents 95517e4 + a79659e commit ac22b14

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.util.concurrent.CountDownLatch;
4848
import java.util.concurrent.ExecutionException;
4949
import java.util.concurrent.ScheduledThreadPoolExecutor;
50+
import java.util.concurrent.TimeUnit;
5051

5152
import fr.free.nrw.commons.CommonsApplication;
5253
import fr.free.nrw.commons.R;
@@ -151,7 +152,7 @@ protected void onPostExecute(ArrayList<String> result) {
151152

152153
//Only return titleCatItems after API call has finished
153154
try {
154-
mergeLatch.await();
155+
mergeLatch.await(5L, TimeUnit.SECONDS);
155156
} catch (InterruptedException e) {
156157
Log.e(TAG, "Interrupted exception: ", e);
157158
}
@@ -204,7 +205,7 @@ protected ArrayList<String> mergeItems() {
204205

205206
//Await results of titleItems, which is likely to come in last
206207
try {
207-
mergeLatch.await();
208+
mergeLatch.await(5L, TimeUnit.SECONDS);
208209
Log.d(TAG, "Waited for merge");
209210
} catch (InterruptedException e) {
210211
Log.e(TAG, "Interrupted Exception: ", e);

0 commit comments

Comments
 (0)