我正在尝试使用 ttorrent 库为 android 创建 torrent 应用程序。我有一些问题。
05-29 23:07:23.388: E/AndroidRuntime(3681): 致命异常: bt-announce(..393337)
05-29 23:07:23.388: E/AndroidRuntime(3681): java.lang.NullPointerException
05-29 23:07:23.388: E/AndroidRuntime(3681): at com.turn.ttorrent.common.protocol.http.HTTPAnnounceResponseMessage.parse(HTTPAnnounceResponseMessage.java:105)
05-29 23:07:23.388: E/AndroidRuntime(3681): at com.turn.ttorrent.common.protocol.http.HTTPTrackerMessage.parse(HTTPTrackerMessage.java:51)
05-29 23:07:23.388: E/AndroidRuntime(3681): at com.turn.ttorrent.client.announce.HTTPTrackerClient.announce(HTTPTrackerClient.java:124)
05-29 23:07:23.388: E/AndroidRuntime(3681): at com.turn.ttorrent.client.announce.Announce.run(Announce.java:224)
05-29 23:07:23.388: E/AndroidRuntime(3681): 在 java.lang.Thread.run(Thread.java:856)
public static HTTPAnnounceResponseMessage parse(ByteBuffer data)
throws IOException, MessageValidationException {
BEValue decoded = BDecoder.bdecode(data);
if (decoded == null) {
throw new MessageValidationException(
"Could not decode tracker message (not B-encoded?)!");
}
Map<String, BEValue> params = decoded.getMap();
try {
List<Peer> peers;
try {
// First attempt to decode a compact response, since we asked
// for it.
peers = toPeerList(params.get("peers").getBytes());
} catch (InvalidBEncodingException ibee) {
// Fall back to peer list, non-compact response, in case the
// tracker did not support compact responses.
peers = toPeerList(params.get("peers").getList());
}
return new HTTPAnnounceResponseMessage(data,
params.get("interval").getInt(),
params.get("complete").getInt(),
params.get("incomplete").getInt(),
peers);
} catch (InvalidBEncodingException ibee) {
throw new MessageValidationException("Invalid response " +
"from tracker!", ibee);
} catch (UnknownHostException uhe) {
throw new MessageValidationException("Invalid peer " +
"in tracker response!", uhe);
}
没有诸如“间隔”或“完成”或“不完整”之类的键是参数。有两个键“peers”和“min interval”。
据我所知,在我调用客户端方法下载后,它从跟踪器请求了一些信息,然后尝试解析这些信息。这就是错误所在。
那么,问题是为什么会这样?是图书馆出错还是我有什么问题?