私は、時折 ConcurrentModifificationException をスローしている ArrayList で非常に単純な「フィルター」を実行していますが、AFAICT には変更が行われていません...コードは非常に単純です...
public ArrayList<JSONObject> getContributionsByInstallation(int installationID, ArrayList<JSONObject> list){
ArrayList<JSONObject> filtered = new ArrayList<JSONObject>();
for(JSONObject object : list) {
try {
int fk = object.getInt("exhibit_fk");
if(fk == installationID){
filtered.add(object);
}
} catch(JSONException e){
}
}
return filtered;
}
私は何が欠けていますか?
/EDIT: スタック トレースの追加
07-12 12:39:24.135: E/AndroidRuntime(2350): FATAL EXCEPTION: main
07-12 12:39:24.135: E/AndroidRuntime(2350): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whatever.light/com.whatever.light.InstallationDetailActivity}: java.util.ConcurrentModificationException
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.os.Looper.loop(Looper.java:130)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.ActivityThread.main(ActivityThread.java:3691)
07-12 12:39:24.135: E/AndroidRuntime(2350): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 12:39:24.135: E/AndroidRuntime(2350): at java.lang.reflect.Method.invoke(Method.java:507)
07-12 12:39:24.135: E/AndroidRuntime(2350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
07-12 12:39:24.135: E/AndroidRuntime(2350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
07-12 12:39:24.135: E/AndroidRuntime(2350): at dalvik.system.NativeStart.main(Native Method)
07-12 12:39:24.135: E/AndroidRuntime(2350): Caused by: java.util.ConcurrentModificationException
07-12 12:39:24.135: E/AndroidRuntime(2350): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:576)
07-12 12:39:24.135: E/AndroidRuntime(2350): at com.whatever.light.data.ContributionsData.getContrubtionsByInstallation(ContributionsData.java:81)
07-12 12:39:24.135: E/AndroidRuntime(2350): at com.whatever.light.data.ContributionsData.getRandomCommentContribution(ContributionsData.java:62)
07-12 12:39:24.135: E/AndroidRuntime(2350): at com.whatever.light.installations.ContributeCommentModuleFragment.showComment(ContributeCommentModuleFragment.java:102)
07-12 12:39:24.135: E/AndroidRuntime(2350): at com.whatever.light.installations.ContributeCommentModuleFragment.onCreateView(ContributeCommentModuleFragment.java:86)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:844)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1371)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:499)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.Activity.performStart(Activity.java:3817)
07-12 12:39:24.135: E/AndroidRuntime(2350): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
07-12 12:39:24.135: E/AndroidRuntime(2350): ... 11 more