Simplify rejected execution exception

This exception type has several unnecessary constructor overrides so
this commit removes them.

Relates #27664
This commit is contained in:
Jason Tedor 2017-12-05 06:58:34 -05:00 committed by GitHub
parent 1be286c592
commit eb574425b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 18 deletions

View File

@ -246,13 +246,16 @@ public class EsExecutors {
* waiting if necessary for space to become available.
*/
static class ForceQueuePolicy implements XRejectedExecutionHandler {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
try {
// force queue policy should only be used with a scaling queue
assert executor.getQueue() instanceof ExecutorScalingQueue;
executor.getQueue().put(r);
} catch (InterruptedException e) {
//should never happen since we never wait
throw new EsRejectedExecutionException(e);
} catch (final InterruptedException e) {
// a scaling queue never blocks so a put to it can never be interrupted
throw new AssertionError(e);
}
}
@ -260,6 +263,7 @@ public class EsExecutors {
public long rejected() {
return 0;
}
}
}

View File

@ -27,29 +27,20 @@ import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
public class EsRejectedExecutionException extends ElasticsearchException {
private final boolean isExecutorShutdown;
public EsRejectedExecutionException(String message, boolean isExecutorShutdown, Object... args) {
super(message, args);
public EsRejectedExecutionException(String message, boolean isExecutorShutdown) {
super(message, isExecutorShutdown);
this.isExecutorShutdown = isExecutorShutdown;
}
public EsRejectedExecutionException(String message, Object... args) {
this(message, false, args);
}
public EsRejectedExecutionException(String message, boolean isExecutorShutdown) {
this(message, isExecutorShutdown, new Object[0]);
public EsRejectedExecutionException(String message) {
this(message, false);
}
public EsRejectedExecutionException() {
super((String)null);
this.isExecutorShutdown = false;
}
public EsRejectedExecutionException(Throwable e) {
super(null, e);
this.isExecutorShutdown = false;
this(null, false);
}
@Override
@ -79,4 +70,5 @@ public class EsRejectedExecutionException extends ElasticsearchException {
public boolean isExecutorShutdown() {
return isExecutorShutdown;
}
}