Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-1383

An incomplete fix for the resource leak bugs in RemoteManagerHandler.java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • 2.3.0, 2.3.1, 2.3.2
    • None
    • Remote Manager
    • None

    Description

      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(); }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            guangtai Guangtai Liang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified