Source:
public void write(MarshallableEntry<? extends K, ? extends V> marshalledEntry) { try { org.infinispan.commons.io.ByteBuffer key = marshalledEntry.getKeyBytes(); org.infinispan.commons.io.ByteBuffer data = marshalledEntry.getValueBytes(); org.infinispan.commons.io.ByteBuffer metadata = marshalledEntry.getMetadataBytes(); int metadataLength = metadata == null ? 0 : metadata.getLength() + TIMESTAMP_BYTES; int len = KEY_POS + key.getLength() + data.getLength() + metadataLength; FileEntry newEntry; FileEntry oldEntry = null; resizeLock.readLock().lock(); try { newEntry = allocate(len); newEntry = new FileEntry(newEntry.offset, newEntry.size, key.getLength(), data.getLength(), metadataLength, marshalledEntry.expiryTime()); ByteBuffer buf = ByteBuffer.allocate(len); buf.putInt(newEntry.size); buf.putInt(newEntry.keyLen); buf.putInt(newEntry.dataLen); buf.putInt(newEntry.metadataLen); buf.putLong(newEntry.expiryTime); buf.put(key.getBuf(), key.getOffset(), key.getLength()); buf.put(data.getBuf(), data.getOffset(), data.getLength()); if (metadata != null) { buf.put(metadata.getBuf(), metadata.getOffset(), metadata.getLength()); buf.putLong(marshalledEntry.created()); buf.putLong(marshalledEntry.lastUsed()); } buf.flip(); channel.write(buf, newEntry.offset); if (trace) log.tracef("Wrote entry %s:%d at %d:%d", marshalledEntry.getKey(), len, newEntry.offset, newEntry.size); oldEntry = entries.put(marshalledEntry.getKey(), newEntry); if (oldEntry == null) oldEntry = evict(); } finally { try { free(oldEntry); } finally { resizeLock.readLock().unlock(); } } } catch (Exception e) { throw new PersistenceException(e); } }

Target:
public void write(MarshallableEntry<? extends K, ? extends V> marshalledEntry) { try { org.infinispan.commons.io.ByteBuffer key = marshalledEntry.getKeyBytes(); org.infinispan.commons.io.ByteBuffer data = marshalledEntry.getValueBytes(); org.infinispan.commons.io.ByteBuffer metadata = marshalledEntry.getMetadataBytes(); int metadataLength = metadata == null ? 0 : metadata.getLength() + TIMESTAMP_BYTES; int len = KEY_POS + key.getLength() + data.getLength() + metadataLength; FileEntry newEntry; FileEntry oldEntry = null; resizeLock.readLock().lock(); try { newEntry = allocate(len); newEntry = new FileEntry(newEntry.offset, newEntry.size, key.getLength(), data.getLength(), metadataLength, marshalledEntry.expiryTime()); ByteBuffer buf = ByteBuffer.allocate(len); buf.putInt(newEntry.size); buf.putInt(newEntry.keyLen); buf.putInt(newEntry.dataLen); buf.putInt(newEntry.metadataLen); buf.putLong(newEntry.expiryTime); buf.put(key.getBuf(), key.getOffset(), key.getLength()); buf.put(data.getBuf(), data.getOffset(), data.getLength()); if (metadata != null) { buf.put(metadata.getBuf(), metadata.getOffset(), metadata.getLength()); if (newEntry.expiryTime > 0) { buf.putLong(marshalledEntry.created()); buf.putLong(marshalledEntry.lastUsed()); } } buf.flip(); channel.write(buf, newEntry.offset); if (trace) log.tracef("Wrote entry %s:%d at %d:%d", marshalledEntry.getKey(), len, newEntry.offset, newEntry.size); oldEntry = entries.put(marshalledEntry.getKey(), newEntry); if (oldEntry == null) oldEntry = evict(); } finally { try { free(oldEntry); } finally { resizeLock.readLock().unlock(); } } } catch (Exception e) { throw new PersistenceException(e); } }