Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Fixes bug with resource leak #235

Merged
merged 3 commits into from
May 3, 2017

Conversation

bmourat
Copy link
Contributor

@bmourat bmourat commented May 2, 2017

Fixes bug with resource leak crash in a strict mode. A bug can be reproduced with the following code

try {
   for(int i = 0; i < 100; i++){
     Log.d("CYCLE", "i = " + i );
     MetricsManager.trackEvent("Closeable leak");
     Thread.sleep(750 + (long)(Math.random() * 1250));
   }
 } catch (InterruptedException e) {
      e.printStackTrace();
 }

It seems like the problem is not calling disconnect method after the connection is used.

@@ -125,6 +125,9 @@ protected void sendAvailableFiles() {
if ((persistedData != null) && (connection != null)) {
send(connection, fileToSend, persistedData);
}
if (connection != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this problematic?!
send() opens the connection and then, it gets disconnected() right away? Shouldn't we do this once we received the response?

Copy link
Contributor Author

@bmourat bmourat May 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not problematic, we already got the response since send is synchronous.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@ElektrojungeAtWork ElektrojungeAtWork merged commit eaa63c7 into bitstadium:develop May 3, 2017
@bmourat bmourat deleted the fix-closeable-leak branch May 10, 2017 08:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants