clear the list of releases once released
also double check that once a recycler is released, it can't be released again or used
This commit is contained in:
parent
69d88a1edd
commit
1c758b0bb0
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.elasticsearch.common.recycler;
|
package org.elasticsearch.common.recycler;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class NoneRecycler<T> extends Recycler<T> {
|
public class NoneRecycler<T> extends Recycler<T> {
|
||||||
|
@ -39,7 +41,7 @@ public class NoneRecycler<T> extends Recycler<T> {
|
||||||
|
|
||||||
public static class NV<T> implements Recycler.V<T> {
|
public static class NV<T> implements Recycler.V<T> {
|
||||||
|
|
||||||
final T value;
|
T value;
|
||||||
|
|
||||||
NV(T value) {
|
NV(T value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
@ -57,6 +59,10 @@ public class NoneRecycler<T> extends Recycler<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() {
|
public void release() {
|
||||||
|
if (value == null) {
|
||||||
|
throw new ElasticSearchIllegalStateException("recycler entry already released...");
|
||||||
|
}
|
||||||
|
value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.common.recycler;
|
package org.elasticsearch.common.recycler;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
@ -54,7 +55,7 @@ public class QueueRecycler<T> extends Recycler<T> {
|
||||||
|
|
||||||
class QV implements Recycler.V<T> {
|
class QV implements Recycler.V<T> {
|
||||||
|
|
||||||
final T value;
|
T value;
|
||||||
|
|
||||||
QV(T value) {
|
QV(T value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
@ -72,8 +73,12 @@ public class QueueRecycler<T> extends Recycler<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() {
|
public void release() {
|
||||||
|
if (value == null) {
|
||||||
|
throw new ElasticSearchIllegalStateException("recycler entry already released...");
|
||||||
|
}
|
||||||
c.clear(value);
|
c.clear(value);
|
||||||
queue.offer(this);
|
queue.offer(this);
|
||||||
|
value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.common.recycler;
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
import org.apache.lucene.util.CloseableThreadLocal;
|
import org.apache.lucene.util.CloseableThreadLocal;
|
||||||
import org.apache.lucene.util.RamUsageEstimator;
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
|
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +61,7 @@ public class ThreadLocalRecycler<T> extends Recycler<T> {
|
||||||
|
|
||||||
final Stack<T> stack;
|
final Stack<T> stack;
|
||||||
final C<T> c;
|
final C<T> c;
|
||||||
final T value;
|
T value;
|
||||||
|
|
||||||
TV(Stack<T> stack, C<T> c, T value) {
|
TV(Stack<T> stack, C<T> c, T value) {
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
|
@ -81,8 +82,12 @@ public class ThreadLocalRecycler<T> extends Recycler<T> {
|
||||||
@Override
|
@Override
|
||||||
public void release() {
|
public void release() {
|
||||||
assert Thread.currentThread() == stack.thread;
|
assert Thread.currentThread() == stack.thread;
|
||||||
|
if (value == null) {
|
||||||
|
throw new ElasticSearchIllegalStateException("recycler entry already released...");
|
||||||
|
}
|
||||||
c.clear(value);
|
c.clear(value);
|
||||||
stack.push(value);
|
stack.push(value);
|
||||||
|
value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -652,6 +652,7 @@ public class DefaultSearchContext extends SearchContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
clearables.clear();
|
||||||
if (th != null) {
|
if (th != null) {
|
||||||
throw new RuntimeException(th);
|
throw new RuntimeException(th);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue