提交 ab73da1e authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

This field is reset only for the dummy object, so it's OK

上级 d348eca9
...@@ -436,7 +436,7 @@ class FileMemData { ...@@ -436,7 +436,7 @@ class FileMemData {
private final int id; private final int id;
private final boolean compress; private final boolean compress;
private long length; private long length;
private AtomicReference<byte[]>[] buffers; private AtomicReference<byte[]>[] data;
private long lastModified; private long lastModified;
private boolean isReadOnly; private boolean isReadOnly;
private boolean isLockedExclusive; private boolean isLockedExclusive;
...@@ -454,7 +454,7 @@ class FileMemData { ...@@ -454,7 +454,7 @@ class FileMemData {
this.name = name; this.name = name;
this.id = name.hashCode(); this.id = name.hashCode();
this.compress = compress; this.compress = compress;
this.buffers = new AtomicReference[0]; this.data = new AtomicReference[0];
lastModified = System.currentTimeMillis(); lastModified = System.currentTimeMillis();
} }
...@@ -465,7 +465,7 @@ class FileMemData { ...@@ -465,7 +465,7 @@ class FileMemData {
* @return the byte array, or null * @return the byte array, or null
*/ */
byte[] getPage(int page) { byte[] getPage(int page) {
AtomicReference<byte[]>[] b = buffers; AtomicReference<byte[]>[] b = data;
if (page >= b.length) { if (page >= b.length) {
return null; return null;
} }
...@@ -482,7 +482,7 @@ class FileMemData { ...@@ -482,7 +482,7 @@ class FileMemData {
* doesn't match * doesn't match
*/ */
void setPage(int page, byte[] oldData, byte[] newData, boolean force) { void setPage(int page, byte[] oldData, byte[] newData, boolean force) {
AtomicReference<byte[]>[] b = buffers; AtomicReference<byte[]>[] b = data;
if (page >= b.length) { if (page >= b.length) {
return; return;
} }
...@@ -687,12 +687,12 @@ class FileMemData { ...@@ -687,12 +687,12 @@ class FileMemData {
length = len; length = len;
len = MathUtils.roundUpLong(len, BLOCK_SIZE); len = MathUtils.roundUpLong(len, BLOCK_SIZE);
int blocks = (int) (len >>> BLOCK_SIZE_SHIFT); int blocks = (int) (len >>> BLOCK_SIZE_SHIFT);
if (blocks != buffers.length) { if (blocks != data.length) {
AtomicReference<byte[]>[] n = Arrays.copyOf(buffers, blocks); AtomicReference<byte[]>[] n = Arrays.copyOf(data, blocks);
for (int i = buffers.length; i < blocks; i++) { for (int i = data.length; i < blocks; i++) {
n[i] = new AtomicReference<byte[]>(COMPRESSED_EMPTY_BLOCK); n[i] = new AtomicReference<byte[]>(COMPRESSED_EMPTY_BLOCK);
} }
buffers = n; data = n;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论