Author: jukka Date: Wed Apr 23 18:36:13 2014 New Revision: 1589488 URL: http://svn.apache.org/r1589488 Log: OAK-1762: TarMK: Fall back to normal IO when mmap fails
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java?rev=1589488&r1=1589487&r2=1589488&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java Wed Apr 23 18:36:13 2014 @@ -194,20 +194,26 @@ class TarReader { } if (memoryMapping) { - FileAccess mapped = new FileAccess.Mapped(access); - // re-read the index, now with memory mapping - int indexSize = index.remaining(); - index = mapped.read( - mapped.length() - indexSize - 16 - 1024, - indexSize); - return new TarReader(file, mapped, index); - } else { - FileAccess random = new FileAccess.Random(access); - // prevent the finally block from closing the file - // as the returned TarReader will take care of that - access = null; - return new TarReader(file, random, index); + try { + FileAccess mapped = new FileAccess.Mapped(access); + // re-read the index, now with memory mapping + int indexSize = index.remaining(); + index = mapped.read( + mapped.length() - indexSize - 16 - 1024, + indexSize); + return new TarReader(file, mapped, index); + } catch (IOException e) { + log.warn("Failed to mmap tar file " + file + + ", falling back to normal file IO", + e); + } } + + FileAccess random = new FileAccess.Random(access); + // prevent the finally block from closing the file + // as the returned TarReader will take care of that + access = null; + return new TarReader(file, random, index); } } finally { if (access != null) {