diff --git a/pom.xml b/pom.xml index 7a5d51d01..fcb972b41 100755 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 4.0.0 chronicle-map - 2.1.18-SNAPSHOT + 2.2.0-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -48,9 +48,7 @@ pom import - - - + diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 8a248387a..a0ec91d58 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -1271,6 +1271,7 @@ public class ChronicleMapBuilder implements Cloneable, VanillaChronicleMap map = (VanillaChronicleMap) m; map.headerSize = roundUpMapHeaderSize(fis.getChannel().position()); + map.initTransients(this); map.createMappedStoreAndSegments(file); // This is needed to property initialize key and value serialization builders, // which are later used in replication diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index 4feab8ea4..ced3e16c2 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -144,8 +144,8 @@ final class ReplicatedChronicleMap kvChronicleMapBuilder) { + super.initTransients(kvChronicleMapBuilder); closeables = new CopyOnWriteArraySet(); } diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index eced71de7..cc99e5e21 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -88,19 +88,21 @@ class VanillaChronicleMap, final int actualSegments; final long actualChunksPerSegment; final long entriesPerSegment; - final MapEventListener eventListener; - final BytesMapEventListener bytesEventListener; - // if set the ReturnsNull fields will cause some functions to return NULL - // rather than as returning the Object can be expensive for something you probably don't use. - final boolean putReturnsNull; - final boolean removeReturnsNull; final Class nativeValueClass; final MultiMapFactory multiMapFactory; final int maxChunksPerEntry; private final long lockTimeOutNS; - private final ChronicleHashErrorListener errorListener; private final int segmentHeaderSize; private final HashSplitting hashSplitting; + + transient MapEventListener eventListener; + transient BytesMapEventListener bytesEventListener; + // if set the ReturnsNull fields will cause some functions to return NULL + // rather than as returning the Object can be expensive for something you probably don't use. + transient boolean putReturnsNull; + transient boolean removeReturnsNull; + transient ChronicleHashErrorListener errorListener; + transient Provider> keyReaderProvider; transient Provider keyInteropProvider; transient Provider> valueReaderProvider; @@ -184,7 +186,6 @@ class VanillaChronicleMap, greatestCommonDivisor((int) chunkSize, alignment) != alignment; this.specialEntrySpaceOffset = builder.specialEntrySpaceOffset(replicated); - this.errorListener = builder.errorListener(); this.putReturnsNull = builder.putReturnsNull(); this.removeReturnsNull = builder.removeReturnsNull(); @@ -193,13 +194,11 @@ class VanillaChronicleMap, this.entriesPerSegment = builder.entriesPerSegment(replicated); this.multiMapFactory = builder.multiMapFactory(replicated); this.metaDataBytes = builder.metaDataBytes(); - this.eventListener = builder.eventListener(); - this.bytesEventListener = builder.bytesEventListener(); this.segmentHeaderSize = builder.segmentHeaderSize(replicated); this.maxChunksPerEntry = builder.maxChunksPerEntry(); hashSplitting = HashSplitting.Splitting.forSegments(actualSegments); - initTransients(); + initTransients(builder); } static T newInstance(Class aClass, boolean isKey) { @@ -266,7 +265,15 @@ class VanillaChronicleMap, return hashSplitting.segmentIndex(hash); } - void initTransients() { + void initTransients(ChronicleMapBuilder builder) { + if (builder != null) { + this.eventListener = builder.eventListener(); + this.errorListener = builder.errorListener(); + this.putReturnsNull = builder.putReturnsNull(); + this.removeReturnsNull = builder.removeReturnsNull(); + this.bytesEventListener = builder.bytesEventListener(); + } + keyReaderProvider = Provider.of((Class) originalKeyReader.getClass()); keyInteropProvider = Provider.of((Class) originalKeyInterop.getClass()); @@ -353,7 +360,7 @@ class VanillaChronicleMap, private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - initTransients(); + initTransients(null); } /**