ttorrent icon indicating copy to clipboard operation
ttorrent copied to clipboard

IllegalStateException: Trying to download a piece while previous download not completed!

Open chrisawad opened this issue 9 years ago • 10 comments

I'm getting the following all over the place when I download a torrent using the master branch right now.

Exception in thread "bt-peer(..BC5A6F)-recv" java.lang.IllegalStateException: Trying to download a piece while previous download not completed!
    at com.turn.ttorrent.client.peer.SharingPeer.downloadPiece(SharingPeer.java:357)
    at com.turn.ttorrent.client.SharedTorrent.handlePeerReady(SharedTorrent.java:700)
    at com.turn.ttorrent.client.peer.SharingPeer.firePeerReady(SharingPeer.java:654)
    at com.turn.ttorrent.client.peer.SharingPeer.handleMessage(SharingPeer.java:615)
    at com.turn.ttorrent.client.peer.PeerExchange$IncomingThread.run(PeerExchange.java:364)

IllegalStateException is a RuntimeException so it seems like it's being thrown somewhere in the program and not being handled. I can't seem to track down exactly from where & it usually starts flooding the error stream mid way though the download.

Thoughts?

chrisawad avatar Feb 16 '16 03:02 chrisawad

+1

abreksa4 avatar Feb 16 '16 05:02 abreksa4

+1

mianharisali avatar Mar 09 '16 13:03 mianharisali

Looks like this is a long standing issue, see #140

philipphenkel avatar Mar 14 '16 22:03 philipphenkel

+1

saibbyweb avatar Oct 02 '16 05:10 saibbyweb

+1

LIXUANYI avatar Oct 09 '16 07:10 LIXUANYI

+1

yorlov avatar Nov 16 '16 22:11 yorlov

+1

jaydotosh avatar Apr 22 '18 19:04 jaydotosh

+1

LazyDoge avatar May 14 '18 17:05 LazyDoge

+1

gosuhiman avatar Jun 07 '18 15:06 gosuhiman

took a look at the code and it seems like a rather simple fix and it might actually be an issue where the current implementation might not download a requested piece (need to double check this accusation though).

the method handlePeerReady(SharingPeer peer) is called in 2 places and one of them already checks if the peer is currently downloading. it makes more sense to add a check for isDownloading in that handle peer ready method and break out quietly instead of doing anything in that method. my suggestion:

	@Override
	public synchronized void handlePeerReady(SharingPeer peer) {
		if (peer.isDownloading()) return;

	// ... the existing body
	}

is this library being maintained still?

mdeanda avatar Feb 21 '23 05:02 mdeanda