frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
446 stars 137 forks source link

do not try to get a status on an invalid handle #142

Closed gubatron closed 7 years ago

gubatron commented 7 years ago

To avoid this crash:

java.lang.RuntimeException: invalid torrent handle used
    at com.frostwire.jlibtorrent.swig.libtorrent_jni.torrent_handle_status__SWIG_0(Native Method)
    at com.frostwire.jlibtorrent.swig.torrent_handle.status(torrent_handle.java:51)
    at com.frostwire.jlibtorrent.TorrentHandle.status(TorrentHandle.java:195)
    at com.frostwire.jlibtorrent.TorrentHandle.status(TorrentHandle.java:213)
    at com.frostwire.bittorrent.BTDownload.getDownloadSpeed(BTDownload.java:284)
aldenml commented 7 years ago

The problem with doing this at this level is that you will get an outdated status without notice that the torrent is no longer valid, it's better to crash and put the fix in the client, in this case in BTDownload. I already fixed similar ones in frostwire common.

gubatron commented 7 years ago

you're right, I actually came back to close this thinking about it a few mins later, this way you never know.