Multipart request throwing ConcurrentModificationException

25 views
Skip to first unread message

Akinniranye James

unread,
Dec 24, 2016, 5:26:23 PM12/24/16
to CodenameOne Discussions
On the Device and Simulator . I get this  when uploading files using MultipartRequest
java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:711)
at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:734)
at com.codename1.io.MultipartRequest.buildRequestBody(MultipartRequest.java:277)
at com.codename1.io.ConnectionRequest.performOperation(ConnectionRequest.java:621)
at com.codename1.io.NetworkManager$NetworkThread.run(NetworkManager.java:282)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Akinniranye James

unread,
Dec 24, 2016, 5:50:37 PM12/24/16
to CodenameOne Discussions

After inspecting the stack trace the error was from this function
 final LinkedHashMap.Entry<K,V> nextNode() {
            LinkedHashMap.Entry<K,V> e = next;
            if (modCount != expectedModCount)
                throw new ConcurrentModificationException();
            if (e == null)
                throw new NoSuchElementException();
            current = e;
            next = e.after;
            return e;
        }

Akinniranye James

unread,
Dec 24, 2016, 7:19:15 PM12/24/16
to CodenameOne Discussions
I think the error is a result of last update  from codename one, I created a new codename one project and ran this code
 String url = "/forms/d7c37032-714e-49e9-9798-2eaa2b27c070/form_versions/aa2a26f6-d5ea-475d-b6af-b721f64d15c3/form_data/";
                    MultipartRequest request = new MultipartRequest();
                    request.setUrl("http://api.xxxxxxx.com" + url);
                    try {
                        request.addData("json_submission_file", "{}", "application/json");
                    } catch (Exception e) {
                    }
                    NetworkManager.getInstance().addToQueue(request); 
gave several EDT Violation Detected errors


On Saturday, December 24, 2016 at 11:26:23 PM UTC+1, Akinniranye James wrote:

Shai Almog

unread,
Dec 25, 2016, 1:50:18 AM12/25/16
to CodenameOne Discussions
This is a bug that predated the last change but it was masked by the previous implementation and exposed in this one.

We'll fix it in the next update.

The last change was there to fix the ordering of arguments for S3/AWS support: https://www.codenameone.com/blog/preferences-location-popup-order.html

Akinniranye James

unread,
Dec 25, 2016, 1:56:29 AM12/25/16
to CodenameOne Discussions
Thanks for the quick response. can you think of any quick patch? That's the only thing debarring us from launch. 

Akinniranye James

unread,
Dec 25, 2016, 2:00:00 AM12/25/16
to CodenameOne Discussions
I will create my own MultipartRequest class and use Map instead of LinkedHashMap

Akinniranye James

unread,
Dec 25, 2016, 3:46:23 AM12/25/16
to CodenameOne Discussions
I created my own MultipartRequest class, made the necessary corrections. 


On Sunday, December 25, 2016 at 7:50:18 AM UTC+1, Shai Almog wrote:
Reply all
Reply to author
Forward
0 new messages