You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2013/10/25 11:04:54 UTC
svn commit: r1535661 - in /cxf/branches/2.7.x-fixes/api/src:
main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java
test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Author: ay
Date: Fri Oct 25 09:04:54 2013
New Revision: 1535661
URL: http://svn.apache.org/r1535661
Log:
Merged revisions 1535660 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1535660 | ay | 2013-10-25 10:59:16 +0200 (Fri, 25 Oct 2013) | 2 lines
[CXF-5361] Attachments iterator may incorrectly handle its remove op
........
Modified:
cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java
cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java?rev=1535661&r1=1535660&r2=1535661&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java (original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java Fri Oct 25 09:04:54 2013
@@ -83,6 +83,7 @@ public class LazyAttachmentCollection
public Iterator<Attachment> iterator() {
return new Iterator<Attachment>() {
int current;
+ boolean removed;
public boolean hasNext() {
if (attachments.size() > current) {
@@ -106,11 +107,16 @@ public class LazyAttachmentCollection
public Attachment next() {
Attachment a = attachments.get(current);
current++;
+ removed = false;
return a;
}
public void remove() {
- attachments.remove(current);
+ if (removed) {
+ throw new IllegalStateException();
+ }
+ attachments.remove(--current);
+ removed = true;
}
};
Modified: cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=1535661&r1=1535660&r2=1535661&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java (original)
+++ cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java Fri Oct 25 09:04:54 2013
@@ -23,9 +23,11 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -108,6 +110,17 @@ public class AttachmentDeserializerTest
assertTrue(attBody instanceof DelegatingInputStream);
attBody.close();
assertEquals(2, msg.getAttachments().size());
+ List<String> cidlist = new ArrayList<String>();
+ cidlist.add("xfire_logo.jpg");
+ cidlist.add("xfire_logo2.jpg");
+
+ for (Iterator<Attachment> it = msg.getAttachments().iterator(); it.hasNext();) {
+ Attachment a = it.next();
+ assertTrue(cidlist.remove(a.getId()));
+ it.remove();
+ }
+ assertEquals(0, cidlist.size());
+ assertEquals(0, msg.getAttachments().size());
}
@Test