Skip to content

Commit

Permalink
Merge branch 'nfuller-Issue1676't push origin master
Browse files Browse the repository at this point in the history
* nfuller-Issue1676:
  Modify timeout exception / update test expectations
  • Loading branch information
squarejesse committed Jun 12, 2015
2 parents 97262e5 + 5af1d7f commit 65b703f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.net.Authenticator;
import java.net.CookieManager;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -307,8 +308,8 @@ protected HttpOverSpdyTest(Protocol protocol){
try {
readAscii(connection.getInputStream(), Integer.MAX_VALUE);
fail("Should have timed out!");
} catch (IOException e){
assertEquals("timeout", e.getMessage());
} catch (SocketTimeoutException expected) {
assertEquals("timeout", expected.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -2202,7 +2203,7 @@ private void testRedirect(boolean temporary, String method) throws Exception {
try {
in.read(); // if Content-Length was accurate, this would return -1 immediately
fail();
} catch (IOException expected) {
} catch (SocketTimeoutException expected) {
}
}

Expand Down Expand Up @@ -2238,7 +2239,7 @@ protected void configureSocket(Socket socket) throws IOException {
byte[] data = new byte[16 * 1024 * 1024]; // 16 MiB.
out.write(data);
fail();
} catch (IOException expected) {
} catch (SocketTimeoutException expected) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.List;
import okio.AsyncTimeout;
Expand Down Expand Up @@ -596,12 +597,21 @@ private void waitForIo() throws InterruptedIOException {
* notify the waiting thread.
*/
class SpdyTimeout extends AsyncTimeout {

@Override protected void timedOut() {
closeLater(ErrorCode.CANCEL);
}

public void exitAndThrowIfTimedOut() throws InterruptedIOException {
if (exit()) throw new InterruptedIOException("timeout");
@Override protected IOException newTimeoutException(IOException cause) {
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
if (cause != null) {
socketTimeoutException.initCause(cause);
}
return socketTimeoutException;
}

public void exitAndThrowIfTimedOut() throws IOException {
if (exit()) throw newTimeoutException(null /* cause */);
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<!-- Compilation -->
<java.version>1.7</java.version>
<okio.version>1.4.0</okio.version>
<okio.version>1.5.0-SNAPSHOT</okio.version>
<!-- ALPN library targeted to Java 7 -->
<alpn.jdk7.version>7.1.2.v20141202</alpn.jdk7.version>
<!-- ALPN library targeted to Java 8 update 25. -->
Expand Down

0 comments on commit 65b703f

Please sign in to comment.