<p>Replace tail recursion of the <code>AvoidStandbyModeService.play</code> method with an ordinary loop, to prevent a new open JAR resource InputStream + sound file OutputStream (which were created every 4 minute playback) from accumulating on the stack, closing them inside the loop instead. (This also prevents eventual stack overflow.)</p>
<p>Also tidy up <code>FileUtil.resourceToFile</code> and put the JAR URL InputStream in a try-with-resources block, to ensure that it doesn't leak either.</p>
<p>--</p>
<p>Running <em>lsof</em> does reveal an accumulation of file handles without this fix, although not as many as one would expect from a new stream being opened every 4 minutes, suggesting that they were being closed in a finaliser:</p>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/54855381/72689639-5b42b980-3b0b-11ea-93af-2837e26594e3.png"><img src="https://user-images.githubusercontent.com/54855381/72689639-5b42b980-3b0b-11ea-93af-2837e26594e3.png" alt="Screenshot from 2020-01-17 00-14-05" style="max-width:100%;"></a></p>
<p>Also, JProfiler revealed an accumulation of <code>ZipInputStream</code> objects from loading the <em>.aiff</em> JAR resource.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/bisq-network/bisq/pull/3909'>https://github.com/bisq-network/bisq/pull/3909</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Fix potential resource leak in AvoidStandbyModeService</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3909/files#diff-0">common/src/main/java/bisq/common/storage/FileUtil.java</a>
    (19)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3909/files#diff-1">core/src/main/java/bisq/core/app/AvoidStandbyModeService.java</a>
    (74)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/bisq-network/bisq/pull/3909.patch'>https://github.com/bisq-network/bisq/pull/3909.patch</a></li>
  <li><a href='https://github.com/bisq-network/bisq/pull/3909.diff'>https://github.com/bisq-network/bisq/pull/3909.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/3909?email_source=notifications&email_token=AJFFTNRWSYCRCBEU25VKRJ3Q6TJCVA5CNFSM4KI4APB2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHG2CEQ">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNVNSPENGZSM43YPCJTQ6TJCVANCNFSM4KI4APBQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNVES2TZXMZPXMZPWPDQ6TJCVA5CNFSM4KI4APB2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHG2CEQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/3909?email_source=notifications\u0026email_token=AJFFTNRWSYCRCBEU25VKRJ3Q6TJCVA5CNFSM4KI4APB2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHG2CEQ",
"url": "https://github.com/bisq-network/bisq/pull/3909?email_source=notifications\u0026email_token=AJFFTNRWSYCRCBEU25VKRJ3Q6TJCVA5CNFSM4KI4APB2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHG2CEQ",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>