Permalink
Browse files

Fix unprotected ArrayList for parallel access by multiple threads.

  • Loading branch information...
scravy committed Aug 30, 2017
1 parent 1e7d173 commit 7c77e41b30661a5762b7b5a97eca1671ab05b59d
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/main/java/com/netflix/bdp/s3/S3MultipartOutputCommitter.java
@@ -41,10 +41,12 @@
import java.io.ObjectOutputStream;
import java.net.URI;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.Collections;
class S3MultipartOutputCommitter extends FileOutputCommitter {
@@ -249,7 +251,8 @@ public void setupJob(JobContext context) throws IOException {
FileStatus[] pendingCommitFiles = attemptFS.listStatus(
jobAttemptPath, HiddenPathFilter.get());
final List<S3Util.PendingUpload> pending = Lists.newArrayList();
final List<S3Util.PendingUpload> pending =
Collections.synchronizedList(new ArrayList<S3Util.PendingUpload>());
// try to read every pending file and add all results to pending.
// in the case of a failure to read the file, exceptions are held until all
@@ -413,8 +416,8 @@ protected void commitTaskInternal(final TaskAttemptContext context,
// keep track of unfinished commits in case one fails. if something fails,
// we will try to abort the ones that had already succeeded.
final List<S3Util.PendingUpload> commits = Lists.newArrayList();
final List<S3Util.PendingUpload> commits =
Collections.synchronizedList(new ArrayList<S3Util.PendingUpload>());
boolean threw = true;
ObjectOutputStream completeUploadRequests = new ObjectOutputStream(

0 comments on commit 7c77e41

Please sign in to comment.