diff --git a/README.md b/README.md index 92387c6f4..0eee7766e 100644 --- a/README.md +++ b/README.md @@ -483,7 +483,6 @@ when calling getUsing(key,using) you can do this : ``` java BondVOInterface bond = map.getUsing(key,value); try (ReadContext context = map.getUsingLocked(key,bond)) { - long issueDate = bond.getIssueDate(); String symbol = bond.getSymbol(); @@ -537,7 +536,6 @@ a segment write lock, this is unlike the getUsing(key,using) method that holds a ``` java BondVOInterface bond = ... // create your instance try (WriteContext context = map.acquireUsingLocked("one", bond)) { - assert bond == context.value(); long issueDate = bond.getIssueDate(); diff --git a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java index 611af7d7c..d8a7ac3e3 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java @@ -72,7 +72,6 @@ public final class ReplicationHub extends AbstractReplication { @Override public String toString() { - return "ReplicationHub{" + super.toString() + "maxEntrySize=" + maxEntrySize + ", channels=" + Arrays.toString(channels) + '}'; diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java b/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java index 9f42563e6..37b6b2e93 100644 --- a/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java @@ -149,7 +149,6 @@ abstract class AbstractChannelReplicator implements Closeable { */ private Selector openSelector(@NotNull final Selector selector, @NotNull final SelectedSelectionKeySet selectedKeySet) { - try { Class selectorImplClass = @@ -319,7 +318,6 @@ abstract class AbstractChannelReplicator implements Closeable { long throttleIntervalInMillis, long serializedEntrySize, long bitsPerDay) { - this.selector = selector; this.throttleInterval = throttleIntervalInMillis; double bytesPerMs = ((double) bitsPerDay) / DAYS.toMillis(1) / BITS_IN_A_BYTE; @@ -352,7 +350,6 @@ abstract class AbstractChannelReplicator implements Closeable { LOG.debug("Restoring OP_WRITE on all channels"); for (SelectableChannel selectableChannel : channels) { - final SelectionKey selectionKey = selectableChannel.keyFor(selector); if (selectionKey != null) selectionKey.interestOps(selectionKey.interestOps() | OP_WRITE); @@ -425,7 +422,6 @@ abstract class AbstractChannelReplicator implements Closeable { @Override public boolean onEntry(final Bytes entry, final int chronicleId) { - long pos0 = in.position(); // used to denote that this is not a stateless map event @@ -500,9 +496,7 @@ abstract class AbstractChannelReplicator implements Closeable { * @param reconnectionInterval the period to wait before connecting */ private void doConnect(final long reconnectionInterval) { - final Thread thread = new Thread(new Runnable() { - public void run() { SelectableChannel socketChannel = null; try { @@ -514,7 +508,6 @@ abstract class AbstractChannelReplicator implements Closeable { try { closeables.add(socketChannel); } catch (IllegalStateException e) { - // close could have be called from another thread, while we were in Thread.sleep() // which would cause a IllegalStateException closeQuietly(socketChannel); diff --git a/src/main/java/net/openhft/chronicle/map/ChannelProvider.java b/src/main/java/net/openhft/chronicle/map/ChannelProvider.java index 5e59580c1..ea56231c2 100644 --- a/src/main/java/net/openhft/chronicle/map/ChannelProvider.java +++ b/src/main/java/net/openhft/chronicle/map/ChannelProvider.java @@ -115,7 +115,6 @@ final class ChannelProvider implements Closeable { try { final int chronicleId = (int) source.readStopBit(); if (chronicleId < chronicleChannels.length) { - // this channel is has not currently been created so it updates will be ignored if (channelEntryExternalizables[chronicleId] != null) channelEntryExternalizables[chronicleId] @@ -129,7 +128,6 @@ final class ChannelProvider implements Closeable { }; private final byte localIdentifier; final Replica asReplica = new Replica() { - @Override public byte identifier() { return localIdentifier; @@ -138,7 +136,6 @@ final class ChannelProvider implements Closeable { @Override public ModificationIterator acquireModificationIterator( final byte remoteIdentifier, final ModificationNotifier notifier) { - channelDataLock.writeLock().lock(); try { final ModificationIterator result = modificationIterator.get(remoteIdentifier); @@ -146,7 +143,6 @@ final class ChannelProvider implements Closeable { return result; final ModificationIterator result0 = new ModificationIterator() { - @Override public boolean hasNext() { channelDataLock.readLock().lock(); @@ -321,7 +317,6 @@ final class ChannelProvider implements Closeable { } private static ByteBufferBytes toBootstrapMessage(int chronicleChannel, final long lastModificationTime, final byte localIdentifier) { - final ByteBufferBytes writeBuffer = new ByteBufferBytes(ByteBuffer.allocate(1 + 1 + 2 + 8)); writeBuffer.writeByte(BOOTSTRAP_MESSAGE); writeBuffer.writeByte(localIdentifier); @@ -409,7 +404,6 @@ final class ChannelProvider implements Closeable { class SystemQueue { final Replica asReplica = new Replica() { - @Override public byte identifier() { throw new UnsupportedOperationException(); @@ -418,14 +412,12 @@ final class ChannelProvider implements Closeable { @Override public ModificationIterator acquireModificationIterator( final byte remoteIdentifier, final ModificationNotifier modificationNotifier) { - final ModificationIterator result = systemModificationIterator.get(remoteIdentifier); if (result != null) return result; final PayloadProvider iterator = new PayloadProvider() { - final Queue payloads = new LinkedTransferQueue(); @Override @@ -495,7 +487,6 @@ final class ChannelProvider implements Closeable { SystemQueue(DirectBitSet systemModificationIteratorBitSet, AtomicReferenceArray systemModificationIterator, MessageHandler messageHandler) { - this.systemModificationIteratorBitSet = systemModificationIteratorBitSet; this.systemModificationIterator = systemModificationIterator; this.messageHandler = messageHandler; diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 3aa191e31..f19bb87e6 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -51,7 +51,6 @@ public final class ChronicleMapBuilder implements ChronicleMapBuilderI ChronicleMapBuilder of( @NotNull Class keyClass, @NotNull Class valueClass) { - if (valueClass.isEnum()) return new ChronicleMapBuilder(OnHeapUpdatableChronicleMapBuilder.of(keyClass, valueClass)); diff --git a/src/main/java/net/openhft/chronicle/map/CloseablesManager.java b/src/main/java/net/openhft/chronicle/map/CloseablesManager.java index fde2bf3c1..8022e0ab2 100755 --- a/src/main/java/net/openhft/chronicle/map/CloseablesManager.java +++ b/src/main/java/net/openhft/chronicle/map/CloseablesManager.java @@ -32,7 +32,6 @@ final class CloseablesManager implements Closeable { private final List closeables = new ArrayList<>(); public synchronized void add(Closeable closeable) { - if (closeable == null) throw new NullPointerException(); if (!closeables.contains(closeable)) diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java index 0074bdc41..8077e8046 100644 --- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java +++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java @@ -116,12 +116,10 @@ public class NodeDiscovery { = new AtomicReference(new CountDownLatch(1)); final NodeDiscoveryEventListener nodeDiscoveryEventListener = new NodeDiscoveryEventListener() { - @Override public void onRemoteNodeEvent(@NotNull final KnownNodes remoteNodes, @NotNull final ConcurrentExpiryMap proposedIdentifiersWithHost) { - LOG.info("onRemoteNodeEvent " + remoteNodes + ", proposedIdentifiersWithHost=" + proposedIdentifiersWithHost); knownHostPorts.addAll(remoteNodes.addressAndPorts()); @@ -131,7 +129,6 @@ public class NodeDiscovery { for (ProposedNodes proposedIdentifierWithHost : proposedIdentifiersWithHost.values()) { if (!proposedIdentifierWithHost.addressAndPort().equals(ourAddressAndPort)) { - int proposedIdentifier = proposedIdentifierWithHost.identifier(); if (proposedIdentifier != -1) { knownAndProposedIdentifiers.set(proposedIdentifier, true); @@ -216,7 +213,6 @@ public class NodeDiscovery { // we should make a local copy as this may change final RemoteNodeValidator remoteNodeValidator = new RemoteNodeValidator() { - private final ConcurrentMap identifiers = new ConcurrentHashMap(); @@ -286,7 +282,6 @@ public class NodeDiscovery { */ private DirectBitSet orBitSets(@NotNull final DirectBitSet source, @NotNull final DirectBitSet destination) { - // merges the two bit-sets together for (int i = (int) source.nextSetBit(0); i > 0; i = (int) source.nextSetBit(i + 1)) { @@ -320,7 +315,6 @@ public class NodeDiscovery { int count = 0; for (; ; ) { - if (knownIdentifiers.setIfClear(possible)) { return possible; } @@ -404,7 +398,6 @@ class NodeDiscoveryBroadcaster extends UdpChannelReplicator { */ UdpSocketChannelEntryReader(final int serializedEntrySize, @NotNull final BytesMarshallable externalizable) { - // we make the buffer twice as large just to give ourselves headroom in = allocateDirect(serializedEntrySize * 2); @@ -463,7 +456,6 @@ class NodeDiscoveryBroadcaster extends UdpChannelReplicator { UdpSocketChannelEntryWriter(final int serializedEntrySize, @NotNull final BytesMarshallable externalizable, @NotNull final UdpChannelReplicator udpReplicator) { - this.externalizable = externalizable; this.udpReplicator = udpReplicator; @@ -517,7 +509,6 @@ class KnownNodes implements BytesMarshallable { private ATSDirectBitSet atsDirectBitSet; KnownNodes() { - this.activeIdentifiersBitSetBytes = new ByteBufferBytes(ByteBuffer.allocate(128 / 8)); this.addressAndPorts = new ConcurrentSkipListSet(); this.atsDirectBitSet = new ATSDirectBitSet(this.activeIdentifiersBitSetBytes); @@ -562,7 +553,6 @@ class KnownNodes implements BytesMarshallable { @Override public void writeMarshallable(@net.openhft.lang.model.constraints.NotNull Bytes out) { - // make a safe copy final Set addressAndPorts = new HashSet(this.addressAndPorts); @@ -743,7 +733,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable { */ @Override public void writeMarshallable(@net.openhft.lang.model.constraints.NotNull Bytes out) { - if (bootstrapRequired.getAndSet(false)) { writeBootstrap(out); return; @@ -777,7 +766,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable { * @return returns true if the UDP message contains the text 'BOOTSTRAP' */ private ProposedNodes readBootstrapMessage(Bytes in) { - final long start = in.position(); try { @@ -789,7 +777,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable { // reads the text bootstrap for (int i = 0; i < size; i++) { - final byte byteRead = in.readByte(); final byte expectedByte = BOOTSTRAP_BYTES.readByte(i); @@ -811,7 +798,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable { final ProposedNodes bootstrap = readBootstrapMessage(in); if (bootstrap != null) { - if (bootstrap.addressAndPort().equals(this.ourAddressAndPort)) return; @@ -948,7 +934,6 @@ class ConcurrentExpiryMap vClass; ConcurrentExpiryMap(Class kClass, Class vClass) { - this.kClass = kClass; this.vClass = vClass; } @@ -964,7 +949,6 @@ class ConcurrentExpiryMap>() { - @Override public K getKey() { return k; @@ -1029,7 +1012,6 @@ class ConcurrentExpiryMap> e = this.queue.peek(); if (e == null) diff --git a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java index 7bc4362ad..8dc117593 100644 --- a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java @@ -29,7 +29,6 @@ final class OffHeapUpdatableChronicleMapBuilder public static ChronicleMapBuilderI of( @NotNull Class keyClass, @NotNull Class valueClass) { - if (valueClass.isEnum()) return OnHeapUpdatableChronicleMapBuilder.of(keyClass, valueClass); diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index 6f43c5069..9b517eb0c 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -386,7 +386,6 @@ final class ReplicatedChronicleMap implements FindByName { final MapEventListener listener = new MapEventListener() { - // creates a map based on the details that are sent to the map of builders @Override public void onPut(CharSequence key, ChronicleMapBuilderWithChannelId value, @@ -179,7 +178,6 @@ class ReplicationHubFindByName implements FindByName { private ChronicleHashInstanceConfig toReplicatedViaChannel(ChronicleHashBuilder builder, int withChannelId) { - return builder.instance().replicatedViaChannel(replicationHub.createChannel((short) withChannelId)); } diff --git a/src/main/java/net/openhft/chronicle/map/Replicators.java b/src/main/java/net/openhft/chronicle/map/Replicators.java index e2b52da67..df38cbc8e 100644 --- a/src/main/java/net/openhft/chronicle/map/Replicators.java +++ b/src/main/java/net/openhft/chronicle/map/Replicators.java @@ -39,7 +39,6 @@ final class Replicators { static Replicator tcp(final AbstractReplication replication) { return new Replicator() { - @Override protected Closeable applyTo(@NotNull final AbstractChronicleMapBuilder builder, @NotNull final Replica replica, @@ -64,7 +63,6 @@ final class Replicators { static Replicator udp( final UdpTransportConfig replicationConfig) { return new Replicator() { - @Override protected Closeable applyTo(@NotNull final AbstractChronicleMapBuilder builder, @NotNull final Replica map, diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index 2ac46aad4..b73bac2d4 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -179,7 +179,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private ExecutorService lazyExecutorService() { - if (executorService == null) { synchronized (this) { if (executorService == null) @@ -203,7 +202,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon long timeoutAt = System.currentTimeMillis() + timeoutMs; for (; ; ) { - checkTimeout(timeoutAt); // ensures that the excising connection are closed @@ -259,7 +257,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon * closes the existing connections and establishes a new closeables */ private void closeExisting() { - // ensure that any excising connection are first closed if (closeables != null) closeables.closeQuietly(); @@ -397,7 +394,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon */ @Override public synchronized boolean equals(Object object) { - if (this == object) return true; if (object == null || object.getClass().isAssignableFrom(Map.class)) return false; @@ -488,7 +484,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } public synchronized V remove(Object key) { - if (key == null) throw keyNotNullNPE(); @@ -547,7 +542,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon bytes.writeObject(function); return; } catch (IllegalStateException e) { - Throwable cause = e.getCause(); if (cause instanceof IOException && cause.getMessage().contains("Not enough available space")) { @@ -560,7 +554,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } public synchronized void putAll(Map map) { - final long sizeLocation = putReturnsNull ? writeEvent(PUT_ALL_WITHOUT_ACC) : writeEventAnSkip(PUT_ALL); @@ -577,7 +570,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon long timeoutTime = config.timeoutMs() + System.currentTimeMillis(); try { for (; ; ) { - if (clientChannel == null) clientChannel = lazyConnect(config.timeoutMs(), config.remoteAddress()); @@ -597,7 +589,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private synchronized void writeEntriesForPutAll(Map map) { - final int numberOfEntries = map.size(); int numberOfEntriesReadSoFar = 0; @@ -648,7 +639,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private void resizeIfRequired(int numberOfEntries, int numberOfEntriesReadSoFar, final long start) { - final long remaining = bytes.remaining(); if (remaining < maxEntrySize) { @@ -670,7 +660,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private void resizeBuffer(int size, long start) { - if (LOG.isDebugEnabled()) LOG.debug("resizing buffer to size=" + size); @@ -710,7 +699,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } public synchronized void clear() { - // get the data back from the server blockingFetch(writeEventAnSkip(CLEAR)); } @@ -729,7 +717,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon BytesReader valueReader = valueReaderWithSize.readerForLoop(null); for (; ; ) { - final boolean hasMoreEntries = in.readBoolean(); // number of entries in this chunk @@ -766,7 +753,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon final Map result = new HashMap(); for (; ; ) { - final boolean hasMoreEntries = in.readBoolean(); // number of entries in this chunk @@ -812,7 +798,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon final Set result = new HashSet<>(); for (; ; ) { - boolean hasMoreEntries = in.readBoolean(); // number of entries in the chunk @@ -850,7 +835,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon * @return */ private long writeEventAnSkip(EventId event) { - long sizeLocation = writeEvent(event); // skips for the transaction id @@ -911,7 +895,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private Bytes blockingFetch(long sizeLocation) { - try { long startTime = System.currentTimeMillis(); return blockingFetchThrowable(sizeLocation, this.config.timeoutMs(), @@ -926,7 +909,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private Bytes blockingFetch0(long sizeLocation, final long transactionId, long startTime) { - try { return blockingFetchThrowable(sizeLocation, this.config.timeoutMs(), transactionId, startTime); } catch (IOException e) { @@ -943,7 +925,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon final long timeoutTime = startTime + timeOutMs; for (; ; ) { - if (clientChannel == null) clientChannel = lazyConnect(config.timeoutMs(), config.remoteAddress()); @@ -969,7 +950,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } private Bytes blockingFetchReadOnly(long timeoutTime, final long transactionId) { - try { return blockingFetch(timeoutTime, transactionId); } catch (IOException e) { @@ -989,7 +969,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon final int requiredSize = size + SIZE_OF_SIZE; if (bytes.capacity() < requiredSize) { - long pos = bytes.position(); long limit = bytes.position(); bytes.position(limit); @@ -1034,7 +1013,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon private Bytes receive(int requiredNumberOfBytes, long timeoutTime) throws IOException { while (bytes.buffer().position() < requiredNumberOfBytes) { - assert requiredNumberOfBytes <= bytes.capacity(); int len = clientChannel.read(bytes.buffer()); diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index e4b9fd929..8201f6cfb 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -140,7 +140,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable } while (selector.isOpen()) { - registerPendingRegistrations(); final int nSelectedKeys = select(); @@ -157,7 +156,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable opWriteUpdater.applyUpdates(); if (useJavaNIOSelectionKeys) { - // use the standard java nio selector if (nSelectedKeys == 0) @@ -216,7 +214,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable } private void processKey(long approxTime, SelectionKey key) { - try { if (!key.isValid()) @@ -291,7 +288,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable */ void heartBeatMonitor(long approxTime) { - for (int i = activeKeys.nextSetBit(0); i >= 0; i = activeKeys.nextSetBit(i + 1)) { try { final SelectionKey key = selectionKeysStore[i]; @@ -332,12 +328,10 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable */ private void sendHeartbeatIfRequired(final long approxTime, @NotNull final SelectionKey key) { - final Attached attachment = (Attached) key.attachment(); if (attachment.isHandShakingComplete() && attachment.entryWriter.lastSentTime + heartBeatIntervalMillis < approxTime) { - attachment.entryWriter.lastSentTime = approxTime; attachment.entryWriter.writeHeartbeatToBuffer(); @@ -531,7 +525,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable socketChannel.register(selector, OP_READ | OP_WRITE, attached); if (attached.remoteIdentifier == Byte.MIN_VALUE) { - final byte remoteIdentifier = reader.identifierFromBuffer(); if (remoteIdentifier == STATELESS_CLIENT) { @@ -589,7 +582,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable } if (!attached.hasRemoteHeartbeatInterval) { - final long value = reader.remoteHeartbeatIntervalFromBuffer(); if (value == Long.MIN_VALUE) @@ -628,7 +620,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable final Attached attached = (Attached) key.attachment(); if (attached.entryWriter.isWorkIncomplete()) { - final boolean completed = attached.entryWriter.doWork(); if (completed) @@ -668,7 +659,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable int len = attached.entryReader.readSocketToBuffer(socketChannel); if (len == -1) { - if (replicationConfig.autoReconnectedUponDroppedConnection()) { AbstractConnector connector = attached.connector; if (connector != null) @@ -856,7 +846,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable addPendingRegistration(new Runnable() { @Override public void run() { - final Attached attached = new Attached(); attached.connector = ClientConnector.this; @@ -926,7 +915,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable */ @Override public void onChange() { - if (remoteIdentifier != Byte.MIN_VALUE) TcpReplicator.this.opWriteUpdater.set(remoteIdentifier); } @@ -995,11 +983,9 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable final boolean handShakingComplete = attached.isHandShakingComplete(); for (; ; ) { - final boolean wasDataRead = modificationIterator.nextEntry(entryCallback, 0); if (!wasDataRead) { - // if we have no more data to write to the socket then we will // un-register OP_WRITE on the selector, until more data becomes available if (in.position() == 0 && handShakingComplete) @@ -1059,7 +1045,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable * localHeartbeatInterval */ private void writeHeartbeatToBuffer() { - // denotes the state - 0 for a heartbeat in.writeByte(HEARTBEAT.ordinal()); @@ -1124,7 +1109,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable } void resizeBuffer(long size) { - assert size < Integer.MAX_VALUE; if (size < in.capacity()) @@ -1177,12 +1161,10 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable */ void entriesFromBuffer(Attached attached, SelectionKey key) throws InterruptedException, IOException { for (; ; ) { - out.limit(in.position()); // its set to MIN_VALUE when it should be read again if (state == NOT_SET) { - if (out.remaining() < SIZE_OF_SIZE + 1) return; @@ -1217,7 +1199,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable if (isStateless) { if (statelessServerConnector == null) { - LOG.error("", new IllegalArgumentException("received an event " + "from a stateless map, stateless maps are not " + "currently supported when using Chronicle Channels")); @@ -1233,7 +1214,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable // fill out the write buffer, so this data will be send when the buffer // is no longer full, and as such is treated as future work if (futureWork != null) { - try { // we will complete what we can for now boolean isComplete = futureWork.doWork(attached.entryWriter.in); if (!isComplete) @@ -1260,7 +1240,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable * compacts the buffer and updates the {@code in} and {@code out} accordingly */ private void compactBuffer() { - // the maxEntrySizeBytes used here may not be the maximum size of the entry in its serialized form // however, its only use as an indication that the buffer is becoming full and should be compacted // the buffer can be compacted at any time @@ -1335,12 +1314,10 @@ class StatelessServerConnector { Work processStatelessEvent(final byte eventId, @NotNull final Bytes writer, @NotNull final ByteBufferBytes reader) { - final StatelessChronicleMap.EventId event = VALUES[eventId]; // these methods don't return a result switch (event) { - case KEY_SET: return keySet(reader, writer); @@ -1365,7 +1342,6 @@ class StatelessServerConnector { // these methods return a result switch (event) { - case LONG_SIZE: return longSize(reader, writer, sizeLocation); @@ -1490,7 +1466,6 @@ class StatelessServerConnector { } private Work longSize(Bytes reader, Bytes writer, final long sizeLocation) { - try { writer.writeLong(map.longSize()); } catch (Throwable e) { @@ -1501,7 +1476,6 @@ class StatelessServerConnector { } private Work hashCode(Bytes reader, Bytes writer, final long sizeLocation) { - try { writer.writeInt(map.hashCode()); } catch (Throwable e) { @@ -1513,7 +1487,6 @@ class StatelessServerConnector { } private Work toString(Bytes reader, Bytes writer, final long sizeLocation) { - final String str; final long remaining = writer.remaining(); @@ -1536,7 +1509,6 @@ class StatelessServerConnector { } private Work sendException(Bytes writer, long sizeLocation, Throwable e) { - // move the position to ignore any bytes written so far writer.position(sizeLocation + HEADER_SIZE); @@ -1547,7 +1519,6 @@ class StatelessServerConnector { } private Work isEmpty(Bytes reader, Bytes writer, final long sizeLocation) { - try { writer.writeBoolean(map.isEmpty()); } catch (Throwable e) { @@ -1679,7 +1650,6 @@ class StatelessServerConnector { } private Work putAll(Bytes reader) { - if (MAP_SUPPORTS_BYTES) { map.putAll(reader); } else { @@ -1690,7 +1660,6 @@ class StatelessServerConnector { } private Work clear(Bytes reader, Bytes writer, final long sizeLocation) { - try { map.clear(); } catch (Throwable e) { @@ -1702,7 +1671,6 @@ class StatelessServerConnector { } private Work values(Bytes reader, Bytes writer) { - final long transactionId = reader.readLong(); Collection values; @@ -1717,7 +1685,6 @@ class StatelessServerConnector { // this allows us to write more data than the buffer will allow return new Work() { - @Override public boolean doWork(Bytes out) { final long sizeLocation = header(out, transactionId); @@ -1727,7 +1694,6 @@ class StatelessServerConnector { int count = 0; while (iterator.hasNext()) { - // we've filled up the buffer, so lets give another channel a chance to send // some data, we don't know the max key size, we will use the entrySize instead if (out.remaining() <= maxEntrySizeBytes) { @@ -1761,7 +1727,6 @@ class StatelessServerConnector { // this allows us to write more data than the buffer will allow return new Work() { - @Override public boolean doWork(Bytes out) { final long sizeLocation = header(out, transactionId); @@ -1771,7 +1736,6 @@ class StatelessServerConnector { int count = 0; while (iterator.hasNext()) { - // we've filled up the buffer, so lets give another channel a chance to send // some data, we don't know the max key size, we will use the entrySize instead if (out.remaining() <= maxEntrySizeBytes) { @@ -1791,7 +1755,6 @@ class StatelessServerConnector { } private Work entrySet(final Bytes reader, Bytes writer) { - final long transactionId = reader.readLong(); final Set> entries; @@ -1806,7 +1769,6 @@ class StatelessServerConnector { // this allows us to write more data than the buffer will allow return new Work() { - @Override public boolean doWork(Bytes out) { if (out.remaining() <= maxEntrySizeBytes) @@ -1821,11 +1783,9 @@ class StatelessServerConnector { int count = 0; while (iterator.hasNext()) { - // we've filled up the buffer, so lets give another channel a chance to send // some data, we don't know the max key size, we will use the entrySize instead if (out.remaining() <= maxEntrySizeBytes) { - writeHeader(out, sizeLocation, count, true); return false; } diff --git a/src/main/java/net/openhft/chronicle/map/UdpChannelReplicator.java b/src/main/java/net/openhft/chronicle/map/UdpChannelReplicator.java index 03028884c..0ec606d45 100644 --- a/src/main/java/net/openhft/chronicle/map/UdpChannelReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/UdpChannelReplicator.java @@ -109,7 +109,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica. try { while (selector.isOpen()) { - registerPendingRegistrations(); // this may block for a long time, upon return the @@ -127,7 +126,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica. final Set selectionKeys = selector.selectedKeys(); for (final SelectionKey key : selectionKeys) { - try { if (key.isReadable()) { @@ -207,7 +205,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica. } private void enableWrites() { - if (writeChannel == null) return; @@ -223,7 +220,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica. } void disableWrites() { - if (writeChannel == null) return; @@ -272,7 +268,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica. addPendingRegistration(new Runnable() { @Override public void run() { - try { server.register(selector, OP_WRITE); writeChannel = server; diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 7a3e89956..4ba59a3e7 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -571,7 +571,6 @@ class VanillaChronicleMap, public Future getLater(@NotNull K key) { final V v = get(key); return new Future() { - @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; @@ -604,7 +603,6 @@ class VanillaChronicleMap, public Future putLater(@NotNull K key, @NotNull V value) { final V v = put(key, value); return new Future() { - @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; @@ -637,7 +635,6 @@ class VanillaChronicleMap, public Future removeLater(@NotNull K key) { final V v = remove(key); return new Future() { - @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; @@ -714,12 +711,10 @@ class VanillaChronicleMap, private void registerConverter(XStream xstream) { final Converter converter = new Converter() { - final Bytes buffer = XStreamConverter.this.buffer; @Override public boolean canConvert(Class aClass) { - if (EntrySet.class.isAssignableFrom(aClass) || WriteThroughEntry.class.isAssignableFrom(aClass)) return true; @@ -738,9 +733,7 @@ class VanillaChronicleMap, @Override public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext marshallingContext) { - if (WriteThroughEntry.class.isAssignableFrom(o.getClass())) { - final SimpleEntry e = (SimpleEntry) o; writer.startNode("chronicle-key"); @@ -760,7 +753,6 @@ class VanillaChronicleMap, writer.endNode(); } else if (EntrySet.class .isAssignableFrom(o.getClass())) { - for (Entry e : (EntrySet) o) { writer.startNode("chronicle-entry"); marshallingContext.convertAnother(e); @@ -824,7 +816,6 @@ class VanillaChronicleMap, private E get(HierarchicalStreamReader reader, UnmarshallingContext unmarshallingContext, Class clazz) { - if (reader.getAttributeCount() > 0) { final String type = reader.getAttribute("type"); try { diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index 418ad20bb..831575868 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -32,7 +32,6 @@ public class CHMUseCasesTest { ChronicleMapBuilder.of(String.class, String.class).statelessClient(CONFIG) )) { try (ChronicleMap map = chmb.create()) { - */ try (ChronicleMap map = ChronicleMapBuilder .of(String.class, String.class) @@ -144,7 +143,6 @@ public class CHMUseCasesTest { .of(StringValue.class, StringValue.class) .checkSerializedValues() // for testng purposes only .create()) { - StringValue key1 = DataValueClasses.newDirectInstance(StringValue.class); StringValue key2 = DataValueClasses.newInstance(StringValue.class); StringValue value1 = DataValueClasses.newDirectInstance(StringValue.class); @@ -295,7 +293,6 @@ public class CHMUseCasesTest { .entrySize(16) .disableOversizedEntries(true) // disabled for testing purposes only. .create()) { - map.put(1L, 11L); assertEquals((Long) 11L, map.get(1L)); @@ -343,7 +340,6 @@ public class CHMUseCasesTest { .disableOversizedEntries(true) // disabled for testing purposes only. .entrySize(16) .create()) { - map.put(1.0, 11.0); assertEquals((Double) 11.0, map.get(1.0)); @@ -763,7 +759,6 @@ public class CHMUseCasesTest { .disableOversizedEntries(true) // disabled for testing purposes only. .entrySize(6) .create()) { - IntValue key1 = DataValueClasses.newDirectInstance(IntValue.class); IntValue key2 = DataValueClasses.newInstance(IntValue.class); ShortValue value1 = DataValueClasses.newDirectInstance(ShortValue.class); @@ -1420,7 +1415,6 @@ public class CHMUseCasesTest { .of(String.class, (Class>) (Class) List.class) .valueMarshaller(ListMarshaller.of(new StringMarshaller(8))) .create()) { - map.put("1", Collections.emptyList()); map.put("2", Arrays.asList("one")); @@ -1451,7 +1445,6 @@ public class CHMUseCasesTest { .of(String.class, (Class>) (Class) Set.class) .valueMarshaller(SetMarshaller.of(new StringMarshaller(8))) .create()) { - map.put("1", Collections.emptySet()); map.put("2", new LinkedHashSet(Arrays.asList("one"))); @@ -1482,7 +1475,6 @@ public class CHMUseCasesTest { .of(String.class, (Class>) (Class) Map.class) .valueMarshaller(MapMarshaller.of(new StringMarshaller(16), new StringMarshaller(16))) .create()) { - map.put("1", Collections.emptyMap()); map.put("2", mapOf("one", "uni")); @@ -1513,7 +1505,6 @@ public class CHMUseCasesTest { .of(String.class, (Class>) (Class) Map.class) .valueMarshaller(MapMarshaller.of(new StringMarshaller(16), new GenericEnumMarshaller(Integer.class, 16))) .create()) { - map.put("1", Collections.emptyMap()); map.put("2", mapOf("one", 1)); diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java index d48a1afdf..1ddb86d9a 100644 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java @@ -29,7 +29,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap expected = ChronicleMapBuilder.of(String.class, String .class) .create()) { - expected.put("hello", "world"); expected.put("aKey", "aValue"); expected.getAll(file); @@ -37,7 +36,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap actual = ChronicleMapBuilder.of(String.class, String .class) .create()) { - actual.putAll(file); Assert.assertEquals(expected, actual); @@ -57,7 +55,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap expected = ChronicleMapBuilder.of(String.class, Map .class) .create()) { - HashMap data = new HashMap<>(); data.put("myKey", "myValue"); expected.put("hello", data); @@ -66,7 +63,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap actual = ChronicleMapBuilder.of(String.class, Map .class) .create()) { - actual.putAll(file); Assert.assertEquals(expected, actual); @@ -85,7 +81,6 @@ public class ChronicleMapImportExportTest { System.out.println(file.getAbsoluteFile()); try (ChronicleMap expected = ChronicleMapBuilder.of (String.class, Map.class).create()) { - HashMap data = new HashMap<>(); HashMap data2 = new HashMap<>(); data2.put("nested", "map"); @@ -97,7 +92,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap actual = ChronicleMapBuilder.of(String.class, Map .class) .create()) { - actual.putAll(file); Assert.assertEquals(expected, actual); @@ -116,7 +110,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap expected = ChronicleMapBuilder.of(Integer.class, Double .class) .create()) { - expected.put(1, 1.0); expected.getAll(file); @@ -124,7 +117,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap actual = ChronicleMapBuilder.of(Integer.class, Double .class) .create()) { - actual.putAll(file); Assert.assertEquals(expected, actual); @@ -144,7 +136,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap expected = ChronicleMapBuilder.of(CharSequence.class, CharSequence .class) .create()) { - expected.put("hello", "world"); expected.getAll(file); @@ -152,7 +143,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap actual = ChronicleMapBuilder.of(CharSequence.class, CharSequence .class) .create()) { - actual.putAll(file); Assert.assertEquals(expected, actual); @@ -173,7 +163,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap expected = ChronicleMapBuilder.of(CharSequence.class, LongValue .class) .create()) { - LongValue value = new LongValue$$Native(); // this will add the entry @@ -189,7 +178,6 @@ public class ChronicleMapImportExportTest { try (ChronicleMap actual = ChronicleMapBuilder.of(CharSequence.class, LongValue .class) .create()) { - actual.putAll(file); Assert.assertEquals(expected, actual); diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index 30e353e5d..54906f545 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -1479,7 +1479,6 @@ public class ChronicleMapTest { .entrySize(16); try (final ChronicleMap map = builder.create()) { - // this will add the entry try (WriteContext context = map.acquireUsingLocked("one", "")) { // do nothing @@ -1496,7 +1495,6 @@ public class ChronicleMapTest { .entrySize(40) .defaultValue("") .create()) { - StringBuilder value = new StringBuilder(); try (WriteContext context = map.acquireUsingLocked("one", value)) { diff --git a/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java b/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java index 03836a343..b98e46e2b 100644 --- a/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java +++ b/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java @@ -59,7 +59,6 @@ public class ConcurrentMap8Test extends JSR166TestCase { } private static ConcurrentMap newIntegerStringMap() { - final ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapBuilder.of(Integer.class, String.class); diff --git a/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java b/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java index 7605dbc3a..0e5481e40 100644 --- a/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java +++ b/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java @@ -57,7 +57,6 @@ public class ConstantSizeBySampleTest { .entries(100) .actualSegments(1) .create()) { - byte[] value = new byte[512 * 1024]; value[42] = 1; @@ -95,7 +94,6 @@ public class ConstantSizeBySampleTest { .entries(100) .actualSegments(1) .create()) { - ExternalizableData value = new ExternalizableData(); value.data[42] = 1; map.put(1L, value); @@ -123,7 +121,6 @@ public class ConstantSizeBySampleTest { .entries(100) .actualSegments(1) .create()) { - SerializableData value = new SerializableData(); value.data[42] = 1; map.put(1L, value); diff --git a/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java index 59a10358c..708345a55 100755 --- a/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java @@ -23,7 +23,6 @@ public class DemoChronicleMapTest { .removeReturnsNull(true) .entries(maxEntries) .createPersistedTo(file)) { - IntValue key = DataValueClasses.newDirectInstance(IntValue.class); DemoOrderVOInterface value = DataValueClasses.newDirectReference(DemoOrderVOInterface.class); @@ -44,7 +43,6 @@ public class DemoChronicleMapTest { } for (Map.Entry entry : map.entrySet()) { - IntValue k = entry.getKey(); DemoOrderVOInterface v = entry.getValue(); @@ -65,7 +63,6 @@ public class DemoChronicleMapTest { .removeReturnsNull(true) .entries(maxEntries) .createPersistedTo(file)) { - IntValue key = DataValueClasses.newDirectInstance(IntValue.class); DemoOrderVOInterface value = DataValueClasses.newDirectReference(DemoOrderVOInterface.class); @@ -88,7 +85,6 @@ public class DemoChronicleMapTest { } for (Map.Entry entry : map.entrySet()) { - IntValue k = entry.getKey(); DemoOrderVOInterface v = entry.getValue(); diff --git a/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java b/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java index 7c723db40..b92da7ed3 100644 --- a/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java @@ -40,7 +40,6 @@ public class IntValueMapTest { .of(IntValue.class, CharSequence.class) .entries(20000) .keyMarshaller(ByteableIntValueMarshaller.INSTANCE).create()) { - IntValue$$Native value = new IntValue$$Native(); value.bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0); diff --git a/src/test/java/net/openhft/chronicle/map/Issue42Test.java b/src/test/java/net/openhft/chronicle/map/Issue42Test.java index 0bdfffb0f..0bb6ff305 100755 --- a/src/test/java/net/openhft/chronicle/map/Issue42Test.java +++ b/src/test/java/net/openhft/chronicle/map/Issue42Test.java @@ -37,7 +37,6 @@ public class Issue42Test { .entrySize(18) .entries(1500000) .minSegments(128).create()) { - for (int i = 0; i < 1000000; ++i) { String s = String.valueOf(i); map.put(s, s); diff --git a/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java b/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java index 0b2a7acc8..10292c16f 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java @@ -58,7 +58,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @Override public V replace(final K key, final V value) { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -70,7 +69,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @Override public int size() { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -84,7 +82,6 @@ public class ReplicationCheckingMap implements ChronicleMap { R r1 = null; R r2 = null; for (int i = 0; i < 50; i++) { - r1 = (R) instance.method(map1); r2 = (R) instance.method(map2); @@ -113,7 +110,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @Override public boolean isEmpty() { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -125,7 +121,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @Override public boolean containsKey(final Object key) { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -137,7 +132,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @Override public boolean containsValue(final Object value) { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -149,7 +143,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @Override public V get(final Object key) { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -182,7 +175,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @NotNull @Override public Set keySet() { - return check(new Call() { @Override public Object method(ConcurrentMap map) { @@ -195,7 +187,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @NotNull @Override public Collection values() { - return check(new Call() { @Override public Collection method(ConcurrentMap map) { @@ -208,7 +199,6 @@ public class ReplicationCheckingMap implements ChronicleMap { @NotNull @Override public Set> entrySet() { - return check(new Call() { @Override public Object method(ConcurrentMap map) { diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java index 0b9b995ab..7c122251d 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java @@ -104,14 +104,12 @@ public class StatelessClientTest { .defaultValue(new StringBuilder()) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)) .create()) { - serverMap.put(10, new StringBuilder("Hello World")); try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, StringBuilder.class) .putReturnsNull(true) .statelessClient(new InetSocketAddress("localhost", port)).create()) { - String actual = statelessMap.mapForKey(10, ToString.INSTANCE); assertEquals("Hello World", actual); @@ -127,13 +125,11 @@ public class StatelessClientTest { .defaultValue(new StringBuilder()) .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)).create()) { - serverMap.put(10, new StringBuilder("Hello World")); try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, StringBuilder.class) .statelessClient(new InetSocketAddress("localhost", port)).create()) { - String actual = statelessMap.mapForKey(11, ToString.INSTANCE); assertEquals(null, actual); @@ -149,12 +145,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", port)) .create()) { - Map payload = new HashMap(); for (int i = 0; i < SIZE; i++) { @@ -182,12 +176,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", port)) .create()) { - Map payload = new HashMap(); for (int i = 0; i < SIZE; i++) { @@ -212,7 +204,6 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", port)) @@ -241,12 +232,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)) .create()) { - serverMap.put(10, "EXAMPLE-10"); try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", port)).create()) { - assertEquals("EXAMPLE-10", statelessMap.get(10)); assertEquals(1, statelessMap.size()); } @@ -259,11 +248,9 @@ public class StatelessClientTest { try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", port)).create()) { - serverMap.put(10, "EXAMPLE-10"); assertEquals("EXAMPLE-10", statelessMap.get(10)); @@ -280,12 +267,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(String.class, Map.class) .statelessClient(new InetSocketAddress("localhost", 8056)) .create()) { - serverMap.put("hello", Collections.singletonMap("hello", "world")); assertEquals(Collections.singletonMap("hello", "world"), statelessMap.get("hello")); @@ -309,12 +294,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(String.class, Map.class) .statelessClient(new InetSocketAddress("localhost", 8056)) .create()) { - statelessMap.put("hello", data); assertEquals(data, serverMap.get("hello")); @@ -330,12 +313,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)) .create()) { - Map payload = new HashMap(); for (int i = 0; i < SIZE; i++) { @@ -360,12 +341,10 @@ public class StatelessClientTest { .entries(SIZE) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)) .create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)) .create()) { - Map payload = new HashMap(); for (int i = 0; i < SIZE; i++) { @@ -388,11 +367,9 @@ public class StatelessClientTest { try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - statelessMap.put(1, "some value"); assertEquals("some value", statelessMap.get(1)); @@ -407,11 +384,9 @@ public class StatelessClientTest { try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - statelessMap.put(1, "some value"); assertEquals("some value", statelessMap.get(1)); @@ -431,11 +406,9 @@ public class StatelessClientTest { try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - statelessMap.put(1, "some value"); assertEquals("some value", statelessMap.getLater(1).get()); @@ -455,11 +428,9 @@ public class StatelessClientTest { try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - CharSequence oldValue = statelessMap.putLater(1, "some value").get(); assertEquals("some value", statelessMap.get(1)); assertEquals(1, statelessMap.size()); @@ -473,7 +444,6 @@ public class StatelessClientTest { try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java index 1f0d1fcbd..927d48959 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java @@ -141,7 +141,6 @@ public class TCPSocketReplicationBootStrapTest { @After public void tearDown() { - for (final Closeable closeable : new Closeable[]{map1, map2}) { try { closeable.close(); diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java index 929546baf..6a907c631 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java @@ -109,7 +109,6 @@ public class TCPSocketReplicationIntValueTest { } private IntValue set(int x) { - value.setValue(x); return value; } @@ -178,7 +177,6 @@ public class TCPSocketReplicationIntValueTest { System.out.print("."); Random rnd = new Random(j); for (int i = 1; i < 10; i++) { - final int select = rnd.nextInt(2); final ChronicleMap map = select > 0 ? map1 : map2; diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java index c7d7a047a..ee97f7ad5 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java @@ -94,7 +94,6 @@ public class TCPSocketReplicationNativeTest { try (WriteContext c = map1 .acquireUsingLocked(1, value)) { - value.setValue(10); } @@ -112,13 +111,11 @@ public class TCPSocketReplicationNativeTest { try (WriteContext c = map1 .acquireUsingLocked(1, value)) { - value.setValue(10); } try (WriteContext c = map1 .acquireUsingLocked(1, value)) { - value.setValue(20); } diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java index c86ca8e92..e25847bbd 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java @@ -113,7 +113,6 @@ public class TCPSocketReplicationPostConnectionTest { @After public void tearDown() { - for (final Closeable closeable : new Closeable[]{map1, map2}) { try { if (closeable != null) diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java index c493e23b7..fff7574f5 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java @@ -154,7 +154,6 @@ public class TCPSocketReplicationTest { System.out.print("."); Random rnd = new Random(j); for (int i = 1; i < 10; i++) { - final int select = rnd.nextInt(2); final ChronicleMap map = select > 0 ? map1 : map2; diff --git a/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java index 643cc3d15..1919c861a 100644 --- a/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java @@ -67,7 +67,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time @@ -125,7 +124,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time @@ -156,7 +154,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time @@ -185,7 +182,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time @@ -245,7 +241,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time @@ -278,7 +273,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time @@ -309,7 +303,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase { .timeProvider(timeProvider) .replication((byte) 1) .create()) { - current(timeProvider); // we do a put at the current time diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/StringEncodingExamplesTest.java b/src/test/java/net/openhft/chronicle/map/fromdocs/StringEncodingExamplesTest.java index c5750a666..d302d14f6 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/StringEncodingExamplesTest.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/StringEncodingExamplesTest.java @@ -195,7 +195,6 @@ public class StringEncodingExamplesTest { .actualSegments(1) .actualEntriesPerSegment(1000) .create()) { - chineseWordSet.add("新闻"); chineseWordSet.add("地图"); chineseWordSet.add("贴吧"); diff --git a/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java index d6701422f..3e30638d2 100644 --- a/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java @@ -95,7 +95,6 @@ public class ChronicleMapTest extends JSR166TestCase { @Test(timeout = 5000) public void testClear() throws IOException { try (ChronicleMap map = map5()) { - map.clear(); assertEquals(0, map.size()); } @@ -154,7 +153,6 @@ public class ChronicleMapTest extends JSR166TestCase { public void testIsEmpty() throws IOException { try (ChronicleMap empty = newShmIntString(8078)) { try (ChronicleMap map = map5()) { - if (!empty.isEmpty()) { System.out.print("not empty " + empty); } @@ -391,7 +389,6 @@ public class ChronicleMapTest extends JSR166TestCase { @Test(timeout = 5000) public void testSize() throws IOException { try (ChronicleMap map = map5()) { - try (ChronicleMap empty = newShmIntString(8078)) { assertEquals(0, empty.size()); assertEquals(5, map.size()); @@ -405,7 +402,6 @@ public class ChronicleMapTest extends JSR166TestCase { @Test(timeout = 10000) public void testSize2() throws IOException { try (ChronicleMap map = map5()) { - try (ChronicleMap empty = newShmIntString(8078)) { assertEquals(0, empty.size()); assertEquals(5, map.size()); @@ -419,7 +415,6 @@ public class ChronicleMapTest extends JSR166TestCase { @Test(timeout = 5000) public void testSize3() throws IOException { try (ChronicleMap map = map5()) { - try (ChronicleMap empty = newShmIntString(8078)) { assertEquals(0, empty.size()); assertEquals(5, map.size()); diff --git a/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java index da5d24a83..3aa530b2c 100755 --- a/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java @@ -343,7 +343,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { @Test(timeout = 10000) public void testClear() throws IOException { try (ChronicleMap map = map5(s_port++)) { - map.clear(); assertEquals(0, map.size()); } @@ -402,7 +401,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { public void testIsEmpty() throws IOException { try (ChronicleMap empty = newShmIntString(s_port++)) { try (ChronicleMap map = map5(s_port++)) { - if (!empty.isEmpty()) { System.out.print("not empty " + empty); } @@ -636,7 +634,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { @Test(timeout = 5000) public void testSize() throws IOException { try (ChronicleMap map = map5(s_port++)) { - try (ChronicleMap empty = newShmIntString(s_port++)) { assertEquals(0, empty.size()); assertEquals(5, map.size()); @@ -650,7 +647,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { @Test(timeout = 15000) public void testSize2() throws IOException { try (ChronicleMap map = map5(s_port++)) { - try (ChronicleMap empty = newShmIntString(s_port++)) { assertEquals(0, empty.size()); assertEquals(5, map.size()); @@ -664,7 +660,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { @Test(timeout = 5000) public void testSize3() throws IOException { try (ChronicleMap map = map5(s_port++)) { - try (ChronicleMap empty = newShmIntString(s_port++)) { assertEquals(0, empty.size()); assertEquals(5, map.size()); diff --git a/src/test/java/net/openhft/chronicle/set/ChronicleSetBuilderTest.java b/src/test/java/net/openhft/chronicle/set/ChronicleSetBuilderTest.java index fd39568f0..b83980ba6 100644 --- a/src/test/java/net/openhft/chronicle/set/ChronicleSetBuilderTest.java +++ b/src/test/java/net/openhft/chronicle/set/ChronicleSetBuilderTest.java @@ -27,7 +27,6 @@ public class ChronicleSetBuilderTest { public void test() throws Exception { try (ChronicleSet integers = ChronicleSetBuilder.of(Integer.class).create()) { - for (int i = 0; i < 10; i++) { integers.add(i); } diff --git a/src/test/java/net/openhft/chronicle/set/Issue3Test.java b/src/test/java/net/openhft/chronicle/set/Issue3Test.java index 3315c6a78..b9df5a0e7 100644 --- a/src/test/java/net/openhft/chronicle/set/Issue3Test.java +++ b/src/test/java/net/openhft/chronicle/set/Issue3Test.java @@ -31,7 +31,6 @@ public class Issue3Test { .actualSegments(1) .actualEntriesPerSegment(1000) .create()) { - Random r = new Random(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 300; j++) {