Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ public void write(final byte[] b, final int off, final int len) {

@Override
public void close() {
withLock(closeLock, () -> {
if (closed) {
return;
}
boolean alreadyClosed = withLock(closeLock, () -> {
boolean prevClosed = closed;
closed = true;
return prevClosed;
});
if (alreadyClosed) {
return;
}
writeChunk();
GridFSFile gridFSFile = new GridFSFile(fileId, filename, lengthInBytes, chunkSizeBytes, new Date(),
metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class GridFSBucketSmokeTestSpecification extends FunctionalSpecification {
def outputStream = gridFSBucket.openUploadStream('myFile')
outputStream.write(contentBytes)
outputStream.close()
outputStream.close() // check for close idempotency
fileId = outputStream.getObjectId()
}

Expand Down