我在Android上运行网络错误。这些不会出现在模拟器或ios版本中。大约75%的时间出现错误,然后一次正常工作。我做了一些调试,网络调用返回0表示响应代码,null表示响应内容。
我已将下面的调用附加到我的get命令中。这段代码多年没有改变(3?)。我现在尝试了两种不同的应用程序,两者都表现出相同的行为。
我已经尝试过回到较旧版本,但我的“专业版”许可证只允许我回到最新版本的???
我知道它不是服务器,因为它适用于iOS和模拟器以及2个不同的应用程序。我一直无法理解这一点。
一个建议?我试图使用新的Rest,但它找不到类(我去了最新)。
public int doGet(final String url) {
if ( Display.getInstance().isEdt() ){
Log.e("*** Performing a GET network call on the EDT");
}
final ConnectionRequest request = new ConnectionRequest() {
@Override
protected void handleException(Exception err) {
if (Dialog.show("Connection error",
"Check your internet connection", "Retry", "Exit")) {
Display.getInstance().exitApplication();
} else {
retry();
}
}
};
request.setUrl(url);
request.setPost(false);
request.setFollowRedirects(false);
request.setReadResponseForErrors(true);
request.setSilentRetryCount(1);
request.addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Log.d("Response code ResponseCodeListener, setting to -1");
responseCode = -1;
}
});
request.addResponseListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
Log.e("Response listener action for GET performed " );
ConnectionRequest cr = (ConnectionRequest) evt.getSource();
responseCode = cr.getResponseCode();
Log.e("Response listener action for GET performed: " + cr.getResponseCode() );
if (cr.getResponseCode() == 200) {
responseData = new String(cr.getResponseData());
} else {
Log.e("Response code: " + cr.getResponseCode() + " of " + cr.getUrl() );
}
}
});
// request will be handled asynchronously
NetworkManager.getInstance().setTimeout(15000);
synchronized (lock) {
depth++;
}
try {
request.setDuplicateSupported(true);
NetworkManager.getInstance().addToQueueAndWait(request);
} finally {
synchronized (lock) {
depth--;
}
}
Log.d("Response: {0} {1}", responseCode, responseData);
return responseCode;
}
日志条目: 02-11 10:08:26.932 20250-20326 /? D /字时间:[Thread-18] 0:0:2,486 - 获取:/ jgame / game / 6647?tkn = 08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
02-11 10:08:26.933 20250-20326/? D/Word Time: [Thread-18] 0:0:2,488 - Calling: GET http://server.wordtimelive.xyz/jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
02-11 10:08:26.934 20250-20326/? D/Word Time: [Thread-18] 0:0:2,489 - Get: http://server.wordtimelive.xyz/jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
02-11 10:08:27.207 20250-20326/? D/Word Time: [Thread-18] 0:0:2,762 - Response: 0 null
02-11 10:08:27.209 20250-20326/? D/Word Time: [Thread-18] 0:0:2,763 - content null of GET: http://server.wordtimelive.xyz/jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
答案 0 :(得分:0)
感谢您对此进行跟踪的帮助。 Steve在此提交https://github.com/codenameone/CodenameOne/commit/685172518e00a7b846993bbc35967cf49a0bc611
中修复了并发修改异常根据描述,听起来这确实是您遇到的问题。它将在明天(2018年2月16日星期五)在服务器中,您可以验证它。