diff --git a/history.txt b/history.txt index 9659dbeb41..478d43784e 100644 --- a/history.txt +++ b/history.txt @@ -1,6 +1,7 @@ 2019-05-02 zzz * GeoIP Maxmind 2019-04-29 * NTCP: Rare EventPumper 100% CPU fix (ticket #2476) + * UPnP: Remove finalize() in HTTPSocket (ticket #2490) 2019-04-25 zzz * Build: Drop unmaintained sample apparmor script (ticket #2319) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 895e8eb464..46b0184db4 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 10; + public final static long BUILD = 11; /** for example "-test" */ public final static String EXTRA = "-rc"; diff --git a/router/java/src/org/cybergarage/http/HTTPServerThread.java b/router/java/src/org/cybergarage/http/HTTPServerThread.java index 7ce1941b5a..d70eb59f81 100644 --- a/router/java/src/org/cybergarage/http/HTTPServerThread.java +++ b/router/java/src/org/cybergarage/http/HTTPServerThread.java @@ -40,15 +40,18 @@ public class HTTPServerThread extends Thread public void run() { HTTPSocket httpSock = new HTTPSocket(sock); - if (httpSock.open() == false) - return; - HTTPRequest httpReq = new HTTPRequest(); - httpReq.setSocket(httpSock); - while (httpReq.read() == true) { - httpServer.performRequestListener(httpReq); - if (httpReq.isKeepAlive() == false) - break; + try { + if (httpSock.open() == false) + return; + HTTPRequest httpReq = new HTTPRequest(); + httpReq.setSocket(httpSock); + while (httpReq.read() == true) { + httpServer.performRequestListener(httpReq); + if (httpReq.isKeepAlive() == false) + break; + } + } finally { + httpSock.close(); } - httpSock.close(); } } diff --git a/router/java/src/org/cybergarage/http/HTTPSocket.java b/router/java/src/org/cybergarage/http/HTTPSocket.java index 837f2dcc5f..f08d357a66 100644 --- a/router/java/src/org/cybergarage/http/HTTPSocket.java +++ b/router/java/src/org/cybergarage/http/HTTPSocket.java @@ -27,6 +27,7 @@ package org.cybergarage.http; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; @@ -51,11 +52,6 @@ public class HTTPSocket setOutputStream(socket.getOutputStream()); } - public void finalize() - { - close(); - } - //////////////////////////////////////////////// // Socket //////////////////////////////////////////////// @@ -133,17 +129,18 @@ public class HTTPSocket public boolean close() { - try { - if (sockIn != null) + if (sockIn != null) + try { sockIn.close(); - if (sockOut != null) + } catch (IOException e) {} + if (sockOut != null) + try { sockOut.close(); - getSocket().close(); - } - catch (Exception e) { - //Debug.warning(e); - return false; - } + } catch (IOException e) {} + if (socket != null) + try { + socket.close(); + } catch (IOException e) {} return true; }