private final Map<AbstractClientHandle<?>, Boolean> openSnapshots = new WeakHashMap<>();
private final ClientLocalHistory history;
+ private final boolean debugAllocation;
- ClientBackedTransactionChain(final ClientLocalHistory history) {
+ ClientBackedTransactionChain(final ClientLocalHistory history, final boolean debugAllocation) {
this.history = Preconditions.checkNotNull(history);
+ this.debugAllocation = debugAllocation;
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new ClientBackedReadTransaction(createSnapshot(), this);
+ return new ClientBackedReadTransaction(createSnapshot(), this, allocationContext());
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new ClientBackedReadWriteTransaction(createTransaction());
+ return new ClientBackedReadWriteTransaction(createTransaction(), allocationContext());
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new ClientBackedWriteTransaction(createTransaction());
+ return new ClientBackedWriteTransaction(createTransaction(), allocationContext());
}
@Override
}
}
+ private Throwable allocationContext() {
+ return debugAllocation ? new Throwable("allocated at") : null;
+ }
+
private synchronized <T extends AbstractClientHandle<?>> T recordSnapshot(final T snapshot) {
openSnapshots.put(snapshot, Boolean.TRUE);
return snapshot;