Loading tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/StorageInternalReader.java +15 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.aconfig.storage; import android.compat.annotation.UnsupportedAppUsage; import java.io.Closeable; import java.io.FileInputStream; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; Loading Loading @@ -68,13 +69,26 @@ public class StorageInternalReader { // Map a storage file given file path private static MappedByteBuffer mapStorageFile(String file) { FileInputStream stream = null; try { FileInputStream stream = new FileInputStream(file); stream = new FileInputStream(file); FileChannel channel = stream.getChannel(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); } catch (Exception e) { throw new AconfigStorageException( String.format("Fail to mmap storage file %s", file), e); } finally { quietlyDispose(stream); } } private static void quietlyDispose(Closeable closable) { try { if (closable != null) { closable.close(); } } catch (Exception e) { // no need to care, at least as of now } } } Loading
tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/StorageInternalReader.java +15 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.aconfig.storage; import android.compat.annotation.UnsupportedAppUsage; import java.io.Closeable; import java.io.FileInputStream; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; Loading Loading @@ -68,13 +69,26 @@ public class StorageInternalReader { // Map a storage file given file path private static MappedByteBuffer mapStorageFile(String file) { FileInputStream stream = null; try { FileInputStream stream = new FileInputStream(file); stream = new FileInputStream(file); FileChannel channel = stream.getChannel(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); } catch (Exception e) { throw new AconfigStorageException( String.format("Fail to mmap storage file %s", file), e); } finally { quietlyDispose(stream); } } private static void quietlyDispose(Closeable closable) { try { if (closable != null) { closable.close(); } } catch (Exception e) { // no need to care, at least as of now } } }