findify / s3mock

Embedded S3 server for easy mocking
MIT License
387 stars 107 forks source link

Multipart upload is not thread-safe #104

Open itaimarts opened 6 years ago

itaimarts commented 6 years ago

In file "InMemoryProvider.scala" on method "putObjectMultipartPart" there is a line which makes the multipartUpload as not thread-safety.

The line - multipartTempStore.getOrElseUpdate(uploadId, new mutable.TreeSet).add(MultipartChunk(partNumber, data))

When some threads call add method (of mutable.TreeSet) at once, it cause parts to be unsorted and therefore completed multipart upload return wrong file!

I suggest that you will use the list of partEtag you got from client in the completeMultipartUpload in order to sort the data properly.