AnantLabs / google-enterprise-connector-manager

Automatically exported from code.google.com/p/google-enterprise-connector-manager
Apache License 2.0
0 stars 1 forks source link

Connections from CM to GSA Being Left Open #196

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm looking at GsaFeedConnection and there may be a problem with the
sendFeedData().

First, note that the class contains 3 URL's.  I believe both the dtdUrl and
the backlogUrl are fine. They are only used with the doGet() method and it
does a finally {disconnect()} on the opened HttpURLConnection.

Now the problem.  Since sendFeedData() could be called by several threads
this will be entered many times.  I'm seeing:

HttpURLConnection uc = feedUrl.openConnection();
// Note this will open a new connection every time.
outputStream = uc.getOutputStream();
  finally {outputStream.close();}
inputStream = uc.getInputStream();
  finally {inputStream.close();}

I do not, however, see a disconnect() call on the uc.

From http://java.sun.com/j2se/1.5.0/docs/api/java/net/HttpURLConnection.html:

"Calling the close() methods on the InputStream or OutputStream of an
HttpURLConnection after a request *may* free network resources associated
with this instance but has no effect on any shared persistent connection.
Calling the disconnect() method may close the underlying socket if a
persistent connection is otherwise idle at that time."

Seems if we just close the input and output streams the connection could be
left open for a while until the socket resources are reclaimed.  If the
Connector is sending a lot of feeds I'm wondering (since socket tear down
can take a while) if this isn't leaving open a lot of connections. 
Eventually they would be reclaimed, however, if the customer limits the
number of connections allowed at one time it could be a problem.

Since we are not reusing the connection it seems like it would be good to
add a disconnect() call.

Original issue reported on code.google.com by mar...@google.com on 4 Nov 2009 at 1:23

GoogleCodeExporter commented 9 years ago
Fixed 04 November 2009 on Connector Manager trunk revision r2228
Fixed 04 November 2009 on Connector Manager 2.0.x branch revision r2229

Original comment by Brett.Mi...@gmail.com on 4 Nov 2009 at 6:51

GoogleCodeExporter commented 9 years ago

Original comment by mar...@google.com on 5 Nov 2009 at 10:55