|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
package org.elasticsearch.common.blobstore.url;
|
|
|
|
|
|
+import org.apache.http.ConnectionClosedException;
|
|
|
import org.elasticsearch.common.SuppressForbidden;
|
|
|
import org.elasticsearch.common.blobstore.BlobContainer;
|
|
|
import org.elasticsearch.common.blobstore.BlobPath;
|
|
@@ -19,14 +20,19 @@ import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
import org.elasticsearch.repositories.blobstore.AbstractBlobContainerRetriesTestCase;
|
|
|
+import org.hamcrest.Matcher;
|
|
|
import org.junit.AfterClass;
|
|
|
import org.junit.BeforeClass;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.net.InetSocketAddress;
|
|
|
import java.net.MalformedURLException;
|
|
|
+import java.net.SocketTimeoutException;
|
|
|
import java.net.URL;
|
|
|
|
|
|
+import static org.hamcrest.Matchers.either;
|
|
|
+import static org.hamcrest.Matchers.instanceOf;
|
|
|
+
|
|
|
@SuppressForbidden(reason = "use a http server")
|
|
|
public class URLBlobContainerRetriesTests extends AbstractBlobContainerRetriesTestCase {
|
|
|
private static URLHttpClient.Factory factory;
|
|
@@ -56,6 +62,14 @@ public class URLBlobContainerRetriesTests extends AbstractBlobContainerRetriesTe
|
|
|
return URLHttpClientIOException.class;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected Matcher<Object> readTimeoutExceptionMatcher() {
|
|
|
+ // If the timeout is too tight it's possible that an URLHttpClientIOException is thrown as that
|
|
|
+ // exception is thrown before reading data from the response body.
|
|
|
+ return either(instanceOf(SocketTimeoutException.class)).or(instanceOf(ConnectionClosedException.class))
|
|
|
+ .or(instanceOf(RuntimeException.class)).or(instanceOf(URLHttpClientIOException.class));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected BlobContainer createBlobContainer(Integer maxRetries,
|
|
|
TimeValue readTimeout,
|