syncloud.google.docs.NonSensitiveRequestRetryer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of syncloud-google-docs Show documentation
Show all versions of syncloud-google-docs Show documentation
Google Docs Syncloud Starage Adapter
The newest version!
package syncloud.google.docs;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpResponseException;
import syncloud.core.log.Logger;
import java.io.IOException;
import java.net.SocketTimeoutException;
public class NonSensitiveRequestRetryer extends ExponentialBackoff {
private static Logger logger = Logger.getLogger(NonSensitiveRequestRetryer.class);
private HttpRequest request;
public HttpResponse execute(HttpRequest request) throws IOException {
this.request = request;
return run();
}
@Override
public HttpResponse process() throws NotReady, IOException {
try {
HttpResponse response = request.execute();
HttpLogger.log(response);
return response;
} catch (HttpResponseException e) {
HttpResponse response = e.getResponse();
int code = response.getStatusCode();
HttpLogger.log(response);
if (code == 500 || code == 503 || code == 400) {
logger.error("error: " + e.getMessage());
throw new NotReady();
} else {
throw e;
}
} catch (SocketTimeoutException e) {
logger.error("error: " + e.getMessage());
throw new NotReady();
} catch (IOException e) {
logger.error("error: " + e.getMessage());
throw e;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy