From 2e080401b1645bd7f7d4804d37d953050d07a9d1 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sun, 27 Jul 2014 18:07:04 +0200 Subject: [PATCH] migrated some ArrayLists to CopyOnWriteArrayLists --- src/eu/siacs/conversations/entities/Account.java | 3 +-- src/eu/siacs/conversations/entities/Conversation.java | 11 ++++++----- src/eu/siacs/conversations/entities/MucOptions.java | 3 ++- .../conversations/persistance/DatabaseBackend.java | 6 +++--- .../conversations/services/XmppConnectionService.java | 2 +- src/eu/siacs/conversations/xmpp/XmppConnection.java | 11 +---------- 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java index b19889bf1..5883788ff 100644 --- a/src/eu/siacs/conversations/entities/Account.java +++ b/src/eu/siacs/conversations/entities/Account.java @@ -1,7 +1,6 @@ package eu.siacs.conversations.entities; import java.security.interfaces.DSAPublicKey; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.concurrent.CopyOnWriteArrayList; @@ -68,7 +67,7 @@ public class Account extends AbstractEntity{ private Roster roster = null; - private List bookmarks = new ArrayList(); + private List bookmarks = new CopyOnWriteArrayList(); public List pendingConferenceJoins = new CopyOnWriteArrayList(); public List pendingConferenceLeaves = new CopyOnWriteArrayList(); diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index 76fe84cfe..29eb22b94 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -1,8 +1,8 @@ package eu.siacs.conversations.entities; import java.security.interfaces.DSAPublicKey; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import net.java.otr4j.OtrException; import net.java.otr4j.crypto.OtrCryptoEngineImpl; @@ -43,7 +43,7 @@ public class Conversation extends AbstractEntity { private String nextPresence; - private transient List messages = null; + private transient CopyOnWriteArrayList messages = null; private transient Account account = null; private transient SessionImpl otrSession; @@ -85,8 +85,9 @@ public class Conversation extends AbstractEntity { } public List getMessages() { - if (messages == null) - this.messages = new ArrayList(); // prevent null pointer + if (messages == null) { + this.messages = new CopyOnWriteArrayList(); // prevent null pointer + } // populate with Conversation (this) @@ -133,7 +134,7 @@ public class Conversation extends AbstractEntity { } } - public void setMessages(List msgs) { + public void setMessages(CopyOnWriteArrayList msgs) { this.messages = msgs; } diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java index 0bb9b295e..3bce5111d 100644 --- a/src/eu/siacs/conversations/entities/MucOptions.java +++ b/src/eu/siacs/conversations/entities/MucOptions.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.entities; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.xml.Element; @@ -81,7 +82,7 @@ public class MucOptions { } } private Account account; - private ArrayList users = new ArrayList(); + private List users = new CopyOnWriteArrayList(); private Conversation conversation; private boolean isOnline = false; private int error = ERROR_ROOM_NOT_FOUND; diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java index 7643076a8..d840721ba 100644 --- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -129,12 +129,12 @@ public class DatabaseBackend extends SQLiteOpenHelper { return list; } - public List getMessages(Conversation conversations, int limit) { + public CopyOnWriteArrayList getMessages(Conversation conversations, int limit) { return getMessages(conversations, limit,-1); } - public List getMessages(Conversation conversation, int limit, long timestamp) { - List list = new CopyOnWriteArrayList(); + public CopyOnWriteArrayList getMessages(Conversation conversation, int limit, long timestamp) { + CopyOnWriteArrayList list = new CopyOnWriteArrayList(); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor; if (timestamp==-1) { diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index c9813d821..3f9b3bfbd 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -668,7 +668,7 @@ public class XmppConnectionService extends Service { @Override public void onIqPacketReceived(Account account, IqPacket packet) { Element query = packet.query(); - List bookmarks = new ArrayList(); + List bookmarks = new CopyOnWriteArrayList(); Element storage = query.findChild("storage", "storage:bookmarks"); if (storage!=null) { for(Element item : storage.getChildren()) { diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index f335d9d47..6d01825e0 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -7,14 +7,8 @@ import java.math.BigInteger; import java.net.Socket; import java.net.UnknownHostException; import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.security.cert.CertPathValidatorException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; @@ -25,16 +19,13 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; + import javax.net.ssl.X509TrustManager; -import org.bouncycastle.pqc.math.linearalgebra.GoppaCode.MaMaPe; import org.xmlpull.v1.XmlPullParserException; import de.duenndns.ssl.MemorizingTrustManager; -import android.content.Context; import android.os.Bundle; import android.os.PowerManager; import android.os.PowerManager.WakeLock;