嗨我得到一个StackOverflowError
,同时将一些小数据发送到我的服务器进行检查,如果它与存储的数据相等。我搜索了一段时间但没有解决方案来解决我的问题。
这是我的AsyncTask代码:
try {
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
return serverRemoteAccessor.checkLoginData(new User("bob@bla.de", "123456"));
}
@Override
protected void onPostExecute(Boolean aBoolean) {
if (aBoolean){
Intent next = new Intent(LoginActivity.this, MainActivity.class);
startActivity(next);
} else {
Toast.makeText(LoginActivity.this,
"Ihre Login-Daten sind nicht korrekt,
bitte überprüfen Sie Ihre Eingaben!",
Toast.LENGTH_SHORT).show();
}
}
}.execute();
} catch (Exception e){
Log.e(LOG_TAG, "Error: " + e);
}
ServerRemoteAccessor代码:
@Override
public boolean checkLoginData(User userData) {
Log.i(LOG_TAG, "checkLogin");
boolean isCorrect = client.checkLoginData(userData);
Log.i(LOG_TAG, "Login is: " + isCorrect);
return isCorrect;
}
我的服务器代码:
@Override
public boolean checkLoginData(User userData) {
logger.info("checkLogin");
User checkLogin = new User("kin@fh-bln.de","123456");
if (checkLogin.equals(userData)){
return true;
}else {
return false;
}
}
我的错误消息:
e.app.malchemie.wunderlist E / AndroidRuntime:FATAL EXCEPTION:AsyncTask#1进程:de.app.malchemie.wunderlist,PID:16191 java.lang.RuntimeException:在android上执行doInBackground()时发生错误。位于java的java.util.concurrent.FutureTask.setException(FutureTask.java:222)的java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)中的os.AsyncTask $ 3.done(AsyncTask.java:304)。 util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:587)在java.lang.Thread.run(Thread.java:818)产生的原因:在libcore.reflect堆栈大小1036KB:java.lang.StackOverflowError的.ListOfTypes.resolveTypes(ListOfTypes.java:70)在libcore.reflect.ListOfTypes.getResolvedTypes(ListOfTypes.java:55)在libcore.reflect.ParameterizedTypeImpl.getResolvedType(ParameterizedTypeImpl.java:75)在libcore.reflect.Types.getType( Types.java:56)at java.lang.Class.getGenericSuperclass(Class.java:1195)在org.jboss.resteasy.util.GenericType。(GenericType.java:34)org.jboss.resteasy.client.core.BaseClientResponse $ 1。(BaseClientResponse.java:89)org.jboss.resteasy.client.core。 BaseClientResponse.copyFromError(BaseClientResponse.java:89)在org.jboss.resteasy.client.ClientResponseFailure。(ClientResponseFailure.java:32)在org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:488)在org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:479)在org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java:384)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:346)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:319)在org.jboss.resteasy.client .core.BaseClientResponse.getEntity(BaseClientResponse.java:442)在org.jboss.resteasy.client.core.BaseClientResponse.copyFromError(BaseClientResponse.java:94)在org.jboss.resteasy.client.ClientResponseFailure(ClientResponseFailure.java: 32)org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:488)at org.jboss.resteasy.client.core.BaseC lientResponse.createResponseFailure(BaseClientResponse.java:479)在org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java:384)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java: 346)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:319)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:442)在org.jboss.resteasy org.jboss.resteasy.client.ClientResponseFailure中的.client.core.BaseClientResponse.copyFromError(BaseClientResponse.java:94)。(ClientResponseFailure.java:32)在org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:488)在org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:479)在org.jboss.resteasy.client .core.BaseClientResponse.readFrom(BaseClientResponse.java:384)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:346)在org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse .java:319)org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:442)在org.jboss.resteasy.client.core.BaseClientResponse.copyFromError(BaseClientResponse.java:94)在org.jboss.resteasy.client.ClientResponseFailure。(ClientResponseFailure.java:32)在org.jboss.resteasy.client.core。 org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:479)中的BaseClientResponse.createResponseFailure(BaseClientResponse.java:488)org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java: 384)at org.jboss.resteasy.client。
编辑:
我解决了我的问题,显然我的对象用户很大,所以我发布了单个字符串,而且一切都还可以。
答案 0 :(得分:2)
使用Asynctask时,您应该创建可在10秒内执行的任务,但结果将是:
答案 1 :(得分:0)
问题在于你的方法调用自身最终导致异常的地方,你需要改变你的逻辑以消除异常。
Override
public boolean checkLoginData(User userData) {
Log.i(LOG_TAG, "checkLogin");
boolean isCorrect = client.checkLoginData(userData);
Log.i(LOG_TAG, "Login is: " + isCorrect);
return isCorrect;
}