aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java37
1 files changed, 20 insertions, 17 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
index e7229ffbd..502e3a70c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -27,9 +27,11 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -133,26 +135,27 @@ public class UncachedKeyRing {
}
try {
- if (mObjectFactory == null) {
- if (stream.available() == 0) {
- // end of stream. that's fine
- return;
+ while(stream.available() > 0) {
+ // if there are no objects left from the last factory, create a new one
+ if (mObjectFactory == null) {
+ mObjectFactory = new PGPObjectFactory(PGPUtil.getDecoderStream(stream));
}
- mObjectFactory = new PGPObjectFactory(PGPUtil.getDecoderStream(stream));
- }
- // go through all objects in this block
- Object obj;
- while ((obj = mObjectFactory.nextObject()) != null) {
- Log.d(Constants.TAG, "Found class: " + obj.getClass());
- if (!(obj instanceof PGPKeyRing)) {
- Log.i(Constants.TAG,
- "Skipping object of bad type " + obj.getClass().getName() + " in stream");
- // skip object
- continue;
+ // go through all objects in this block
+ Object obj;
+ while ((obj = mObjectFactory.nextObject()) != null) {
+ Log.d(Constants.TAG, "Found class: " + obj.getClass());
+ if (!(obj instanceof PGPKeyRing)) {
+ Log.i(Constants.TAG,
+ "Skipping object of bad type " + obj.getClass().getName() + " in stream");
+ // skip object
+ continue;
+ }
+ mNext = new UncachedKeyRing((PGPKeyRing) obj);
+ return;
}
- mNext = new UncachedKeyRing((PGPKeyRing) obj);
- return;
+ // if we are past the while loop, that means the objectFactory had no next
+ mObjectFactory = null;
}
} catch (IOException e) {
Log.e(Constants.TAG, "IOException while processing stream", e);