com.huaweicloud.dis.http.HttpFutureAdapter Maven / Gradle / Ivy
The newest version!
package com.huaweicloud.dis.http;
import java.io.IOException;
import java.util.concurrent.Future;
import org.apache.http.HttpResponse;
import com.huaweicloud.dis.exception.DISClientException;
public class HttpFutureAdapter extends AbstractFutureAdapter implements Future {
private ResponseExtractor responseExtractor;
private ResponseErrorHandler errorHandler;
public HttpFutureAdapter(ResponseExtractor responseExtractor, ResponseErrorHandler errorHandler) {
this.responseExtractor = responseExtractor;
this.errorHandler = errorHandler;
}
@Override
protected T toT(HttpResponse innerT) {
try {
if (errorHandler.hasError(innerT))
{
errorHandler.handleError(innerT);
}
if (responseExtractor != null)
{
return responseExtractor.extractData(innerT);
}else {
return null;
}
} catch (IOException e) {
throw new DISClientException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy