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

View File

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