Remove same-thread checks when recycling (see #5254).

This commit is contained in:
Adrien Grand 2014-02-28 20:48:33 +01:00
parent 7e49848697
commit 7af63700c9
1 changed files with 0 additions and 6 deletions

View File

@ -54,16 +54,10 @@ public class MockPageCacheRecycler extends PageCacheRecycler {
private <T> V<T> wrap(final V<T> v) { private <T> V<T> wrap(final V<T> v) {
ACQUIRED_PAGES.put(v, new Throwable()); ACQUIRED_PAGES.put(v, new Throwable());
final Thread t = Thread.currentThread();
return new V<T>() { return new V<T>() {
@Override @Override
public boolean release() throws ElasticsearchException { public boolean release() throws ElasticsearchException {
if (t != Thread.currentThread()) {
// Releasing from a different thread doesn't break anything but this is bad practice as pages should be acquired
// as late as possible and released as soon as possible in a try/finally fashion
throw new RuntimeException("Page was allocated in " + t + " but released in " + Thread.currentThread());
}
final Throwable t = ACQUIRED_PAGES.remove(v); final Throwable t = ACQUIRED_PAGES.remove(v);
if (t == null) { if (t == null) {
throw new IllegalStateException("Releasing a page that has not been acquired"); throw new IllegalStateException("Releasing a page that has not been acquired");