[ 
https://issues.apache.org/jira/browse/JAMES-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Benoit Tellier closed JAMES-1383.
---------------------------------
    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 RemoteManagerHandler.java
> -------------------------------------------------------------------------
>
>                 Key: JAMES-1383
>                 URL: https://issues.apache.org/jira/browse/JAMES-1383
>             Project: James Server
>          Issue Type: Bug
>          Components: Remote Manager
>    Affects Versions: 2.3.0, 2.3.1, 2.3.2
>            Reporter: Guangtai Liang
>            Priority: Critical
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 108172 was aimed to remove resource leak bugs on the 
> BufferedReader object "in" (created in line 227), the PrintWriter object "out 
> " in the method "handleConnection"of the file 
> "/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
>  (now moved to 
> /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java)"
>  , but it is incomplete.
> There are some problems: 
> 1. when "in" isn't created successfully but the temp InputStreamReader object 
> is created successfully (at line 227), the temp InputStreamReader object will 
> be leaked. 
> 2. when "out" isn't created successfully but the temp BufferedWriter object 
> is created successfully (at line 228), 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 228), 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 257 and the temp BufferedWriter object and the temp 
> OutputStreamWriter object created at line 258 can be leaked). The buggy code 
> is copied as bellows:
>    public void handleConnection( final Socket connection )
>         throws IOException {
>         socket = connection;
>         String remoteIP = socket.getInetAddress().getHostAddress();
>         String remoteHost = socket.getInetAddress().getHostName();
>         synchronized (this) {
>             handlerThread = Thread.currentThread();
>         }
>         try {
> 257            in = new BufferedReader(new 
> InputStreamReader(socket.getInputStream(), "ASCII"), 
> 512);
> 258            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter
> (socket.getOutputStream()), 512), false);
>             ......
>         } catch ( final IOException e ) {
>           ......
>         } finally {
>             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

Reply via email to