From 3b475d5a751685798186b66722d234012c4b610f Mon Sep 17 00:00:00 2001 From: bmckinney Date: Wed, 16 Mar 2016 11:56:12 -0400 Subject: [PATCH] avoids java.util.ConcurrentModificationException when uploading 100+ files --- .../java/edu/harvard/iq/dataverse/EditDatafilesPage.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java b/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java index 50f13919a1f..09a404a1db0 100644 --- a/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java @@ -1020,7 +1020,12 @@ public boolean isDuplicate(FileMetadata fileMetadata) { // more than a certain number of files... Still, needs to be revisited // before the final 4.0. // -- L.A. 4.0 - Iterator fmIt = workingVersion.getFileMetadatas().iterator(); + + // make a "defensive copy" to avoid java.util.ConcurrentModificationException from being thrown + // when uploading 100+ files + List wvCopy = new ArrayList<>(workingVersion.getFileMetadatas()); + Iterator fmIt = wvCopy.iterator(); + while (fmIt.hasNext()) { FileMetadata fm = fmIt.next(); String md5 = fm.getDataFile().getmd5(); @@ -1089,7 +1094,7 @@ private InputStream getDropBoxInputStream(String fileLink, GetMethod dropBoxMeth * Using information from the DropBox choose, ingest the chosen files * https://www.dropbox.com/developers/dropins/chooser/js * - * @param e + * @param event */ public void handleDropBoxUpload(ActionEvent event) {