Ensure HeapBytesStore has final fields for correct visibility, https://github.com/OpenHFT/Chronicle-Wire/issues/137

This commit is contained in:
Peter Lawrey
2019-05-08 19:27:15 +01:00
parent 0b09733cc9
commit 6711903d2c
4 changed files with 21 additions and 18 deletions
@@ -43,7 +43,7 @@ public class ByteArrayDataAccess extends AbstractData<byte[]> implements DataAcc
}
private void initTransients() {
bs = HeapBytesStore.uninitialized();
bs = null;
}
@Override
@@ -77,14 +77,14 @@ public class ByteArrayDataAccess extends AbstractData<byte[]> implements DataAcc
@Override
public Data<byte[]> getData(@NotNull byte[] instance) {
array = instance;
bs.init(instance);
bs = HeapBytesStore.wrap(array);
return this;
}
@Override
public void uninit() {
array = null;
bs.uninit();
bs = null;
}
@Override
@@ -32,7 +32,6 @@ public class ByteBufferDataAccess extends AbstractData<ByteBuffer>
implements DataAccess<ByteBuffer> {
// Cache fields
private transient HeapBytesStore heapBytesStore;
private transient NativeBytesStore nativeBytesStore;
private transient VanillaBytes<Void> bytes;
@@ -45,7 +44,6 @@ public class ByteBufferDataAccess extends AbstractData<ByteBuffer>
}
private void initTransients() {
heapBytesStore = HeapBytesStore.uninitialized();
nativeBytesStore = NativeBytesStore.uninitialized();
bytes = VanillaBytes.vanillaBytes();
}
@@ -91,8 +89,7 @@ public class ByteBufferDataAccess extends AbstractData<ByteBuffer>
nativeBytesStore.init(instance, false);
bytesStore = nativeBytesStore;
} else {
heapBytesStore.init(instance);
bytesStore = heapBytesStore;
bytesStore = HeapBytesStore.wrap(instance);
}
return this;
}
@@ -102,8 +99,6 @@ public class ByteBufferDataAccess extends AbstractData<ByteBuffer>
bb = null;
if (bytesStore == nativeBytesStore) {
nativeBytesStore.uninit();
} else {
heapBytesStore.uninit();
}
}
@@ -29,7 +29,12 @@ public enum ZeroBytesStore implements BytesStore<ZeroBytesStore, Void> {
@Override
public long addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException {
throw new UnsupportedOperationException("todo");
throw new UnsupportedOperationException("Cannot get the address of nothing");
}
@Override
public long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException {
throw new UnsupportedOperationException("Cannot get the address of nothing");
}
@Override