aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorChris Banes <chrisbanes@google.com>2014-02-13 15:18:26 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-02-13 15:18:26 +0000
commite8663307025e1d70c31be991147849504d302529 (patch)
tree3761b1c986bce950da9a5badba2699f4df29f273 /common
parentc39db8c96a707af6575509474c0ce0546807f5b2 (diff)
parent8cb9846e57aac090eb78dae0fcaff14e9ae56be5 (diff)
downloadandroid-e8663307025e1d70c31be991147849504d302529.tar.gz
am 8cb9846e: am 535fde45: Fix possible infinity loop in ag/417350
* commit '8cb9846e57aac090eb78dae0fcaff14e9ae56be5': Fix possible infinity loop in ag/417350
Diffstat (limited to 'common')
-rw-r--r--common/src/java/com/example/android/common/dummydata/Cheeses.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/src/java/com/example/android/common/dummydata/Cheeses.java b/common/src/java/com/example/android/common/dummydata/Cheeses.java
index 220d66a7..783735ce 100644
--- a/common/src/java/com/example/android/common/dummydata/Cheeses.java
+++ b/common/src/java/com/example/android/common/dummydata/Cheeses.java
@@ -174,6 +174,9 @@ public class Cheeses {
Random random = new Random();
HashSet<String> items = new HashSet<String>();
+ // Make sure that don't infinity loop
+ count = Math.min(count, CHEESES.length);
+
while (items.size() < count) {
items.add(CHEESES[random.nextInt(CHEESES.length)]);
}