Skip to content
Permalink
Browse files

Updated AsyncResponseConsumer STOP logic

  • Loading branch information...
lwj5 committed Mar 4, 2019
1 parent 568940b commit 8b55fcd1a3e0760a100702b0f5335768a103f79a
@@ -10,7 +10,7 @@

<groupId>ai.preferred</groupId>
<artifactId>venom</artifactId>
<version>4.1.3</version>
<version>4.1.4-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
@@ -16,10 +16,7 @@

package ai.preferred.venom;

import ai.preferred.venom.fetcher.AsyncFetcher;
import ai.preferred.venom.fetcher.Callback;
import ai.preferred.venom.fetcher.Fetcher;
import ai.preferred.venom.fetcher.StopCodeException;
import ai.preferred.venom.fetcher.*;
import ai.preferred.venom.job.AbstractQueueScheduler;
import ai.preferred.venom.job.Job;
import ai.preferred.venom.job.PriorityQueueScheduler;
@@ -28,6 +25,7 @@
import ai.preferred.venom.request.Request;
import ai.preferred.venom.response.Response;
import ai.preferred.venom.response.VResponse;
import ai.preferred.venom.validator.Validator;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -706,7 +704,8 @@ public void completed(final Request request, final Response response) {
public void failed(final Request request, final Exception ex) {
crawler.connections.release();
crawler.threadPool.execute(() -> {
if (ex instanceof StopCodeException) {
if (ex instanceof StopCodeException
|| (ex instanceof ValidationException && ((ValidationException) ex).getStatus() == Validator.Status.STOP)) {
crawler.pendingJobs.remove(job);
} else {
synchronized (crawler.pendingJobs) {
@@ -265,7 +265,7 @@ protected final BaseResponse buildResult(final HttpContext context) throws Excep
}

if (status == Validator.Status.STOP) {
throw new StopCodeException(statusCode, "Validator stopped the request.");
throw new ValidationException(status, response, "Validator stopped the request.");
} else if (status != Validator.Status.VALID) {
throw new ValidationException(status, response, "Invalid response.");
}

0 comments on commit 8b55fcd

Please sign in to comment.
You can’t perform that action at this time.