[ https://issues.apache.org/jira/browse/JAMES-1381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benoit Tellier closed JAMES-1381. --------------------------------- Resolution: Won't Fix James 2.3 is unmaintained, end of life. Feel free to reopen if work is planned on this. > An incomplete fix for the resource leak bugs in NNTPHandler.java > ---------------------------------------------------------------- > > Key: JAMES-1381 > URL: https://issues.apache.org/jira/browse/JAMES-1381 > Project: James Server > Issue Type: Bug > Components: NNTPServer & Repository (removed) > Affects Versions: 2.3.0, 2.3.1, 2.3.2 > Reporter: Guangtai Liang > Priority: Critical > Labels: incomplete_fix, missing_fixes > Original Estimate: 10m > Remaining Estimate: 10m > > The fix revision 108172 was aimed to remove resource leak bugs on the > BufferedReader object "reader" (created in line 308), the InternetPrintWriter > object "writer" in the method "handleConnection"of the file > "/james/server/trunk/src/java/org/apache/james/nntpserver/NNTPHandler.java > (now moved to > /james/server/branches/v2.3/src/java/org/apache/james/nntpserver/NNTPHandler.java)" > , but it is incomplete. > There are some problems: > 1. when "reader" isn't created successfully but the temp InputStreamReader > object is created successfully (at line 308), the temp InputStreamReader > object will be leaked. > 2. when "writer" isn't created successfully but the temp BufferedWriter > object is created successfully (at line 309), the temp BufferedWriter object > will be leaked. > 3. when the temp BufferedWriter object isn't created successfully but the > temp OutputStreamWriter object is created successfully (at line 309), the > temp OutputStreamWriter object will be leaked. > The best way to close such resource objects is putting such close operations > for all resource > objects in the finaly block of a try-catch-finally structure and then putting > all other code in a try block. > The problem still exists in the head revision (the temp InputStreamReader > object created at line 383 and the "outs" created at line 384 can be leaked). > The buggy code is copied as bellows: > public void handleConnection( Socket connection ) throws IOException { > try { > this.socket = connection; > synchronized (this) { > handlerThread = Thread.currentThread(); > } > remoteIP = socket.getInetAddress().getHostAddress(); > remoteHost = socket.getInetAddress().getHostName(); > in = new BufferedInputStream(socket.getInputStream(), 1024); > // An ASCII encoding can be used because all transmissions other > // that those in the message body command are guaranteed > // to be ASCII > 383 reader = new BufferedReader(new InputStreamReader(in, > "ASCII"), 512); > 384 outs = new BufferedOutputStream(socket.getOutputStream(), > 1024); > 385 writer = new InternetPrintWriter(outs, true); > } catch (Exception e) { > ...... > } > try { > ...... > } catch (Exception e) { > ...... > } finally { > 436 resetHandler(); > } > } -- This message was sent by Atlassian Jira (v8.20.7#820007) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org