findify / s3mock

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

[83] Patch OverlappingFileLockException in GetObject. #92

Closed max8github closed 6 years ago

max8github commented 6 years ago

The error is this when doing GetObject on a pre-existing file of a pre-existing bucket:

java.nio.channels.OverlappingFileLockException: null
    at java.base/sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
    at java.base/sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
    at java.base/sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1121)
    at java.base/java.nio.channels.FileChannel.tryLock(FileChannel.java:1160)
    at org.iq80.leveldb.impl.DbLock.<init>(DbLock.java:47)
    at org.iq80.leveldb.impl.DbImpl.<init>(DbImpl.java:167)
    at org.iq80.leveldb.impl.Iq80DBFactory.open(Iq80DBFactory.java:82)
    at io.findify.s3mock.provider.metadata.MapMetadataStore.load(MapMetadataStore.scala:50)
    at io.findify.s3mock.provider.metadata.MapMetadataStore.get(MapMetadataStore.scala:26)
    at io.findify.s3mock.provider.FileProvider.getObject(FileProvider.scala:89)
    at io.findify.s3mock.route.GetObject.$anonfun$route$4(GetObject.scala:31)
    at scala.util.Try$.apply(Try.scala:209)
    at io.findify.s3mock.route.GetObject.$anonfun$route$3(GetObject.scala:31)

This happens when running s3Mock with the current docker image (openjdk:9.0.1-11-jre-slim), not when running Main locally.

Not all platforms implement file locking the same way: this is a quick fix to a locking problem.

One docker image that works is the one edited here, jdk 8. Other images may work as well.

A different (and better fix) would entail changing the code doing locking.