From b3ed9bc29f590e0aba201f8635157dec17d76f2a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 17 Feb 2019 18:19:45 +0100 Subject: [PATCH] Add BooleansUtils --- .../smack/util/BooleansUtils.java | 30 +++++++++++++++++++ .../smack/XmppConnectionStressTest.java | 7 ++--- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/util/BooleansUtils.java diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/BooleansUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/BooleansUtils.java new file mode 100644 index 000000000..35bce33f8 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/BooleansUtils.java @@ -0,0 +1,30 @@ +/** + * + * Copyright 2019 Florian Schmaus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smack.util; + +public class BooleansUtils { + + public static boolean contains(boolean[] array, boolean target) { + for (boolean b : array) { + if (b == target) { + return true; + } + } + return false; + } + +} diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/XmppConnectionStressTest.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/XmppConnectionStressTest.java index 2574a3970..06d7e5a9f 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/XmppConnectionStressTest.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/XmppConnectionStressTest.java @@ -33,6 +33,7 @@ import org.jivesoftware.smack.filter.StanzaExtensionFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.util.Async; +import org.jivesoftware.smack.util.BooleansUtils; import org.jivesoftware.smack.util.MultiMap; import org.jivesoftware.smack.util.StringUtils; @@ -171,10 +172,8 @@ public class XmppConnectionStressTest { } for (boolean[] markers : myReceiveMarkers.values()) { - for (boolean b : markers) { - if (!b) { - return; - } + if (BooleansUtils.contains(markers, false)) { + return; } } // All markers set to true, this means we received all messages.