Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java

Issue 787803004: Update from https://crrev.com/307664 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ssl/ssl_config.cc ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
diff --git a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
index 6121a2a0206f0aeb7ce30ad000b289a1aff362b9..dd40220a5564fc9b9cdfc654f86294b6d026b690 100644
--- a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
+++ b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
@@ -612,8 +612,9 @@ public class TestWebServer {
HttpParams params = new BasicHttpParams();
params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
while (!mIsCancelled) {
+ Socket socket = null;
try {
- Socket socket = mSocket.accept();
+ socket = mSocket.accept();
DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
conn.bind(socket, params);
@@ -628,8 +629,9 @@ public class TestWebServer {
HttpResponse response = mServer.getResponse(request);
conn.sendResponseHeader(response);
conn.sendResponseEntity(response);
- conn.close();
+ conn.close();
+ socket = null;
} catch (IOException e) {
// normal during shutdown, ignore
Log.w(TAG, e);
@@ -641,6 +643,18 @@ public class TestWebServer {
// DefaultHttpServerConnection's close() throws an
// UnsupportedOperationException.
Log.w(TAG, e);
+ } finally {
+ // Since DefaultHttpServerConnection can raise an exception
+ // during conn.close() (in the case of SSL), we always force
+ // the socket to close, since it may be left open. This will
+ // be a no-op if the connection managed to close the socket.
+ if (socket != null) {
+ try {
+ socket.close();
+ } catch (IOException ignored) {
+ // safe to ignore
+ }
+ }
}
}
try {
« no previous file with comments | « net/ssl/ssl_config.cc ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698