mark-christiaens/xtext — Issue #35: Bug in DefaultCacheIndex#remove(BigInteger)
Author: knutwannheden
Created: 2012-02-12 09:13:45+00:00
State: open

To me it looks like there is a bug in DefaultCacheIndex#remove(BigInteger). When calling entriesMap#remove() the parameter should be the key (digest) and not the value (entry). Thus instead of:

```java
public void remove(BigInteger digest) {
checkInvariants();

ICacheEntry entry = entriesMap.get(digest);

if (entry != null) {
totalOrigContentSize -= entry.getOrigContentSize();
entriesMap.remove(entry);
lruSet.remove(entry);
}
checkInvariants();
}
```
something like:

```java
public void remove(BigInteger digest) {
checkInvariants();

ICacheEntry entry = entriesMap.remove(digest);

if (entry != null) {
totalOrigContentSize -= entry.getOrigContentSize();
lruSet.remove(entry);
}
checkInvariants();
}
```

would be correct.