这很奇怪
当我尝试使用以下代码在后台使用RX处理文件
// this code lies in a RX statement
FirebaseStorage
.getInstance()
.getReference(path) // file path. which does not exist
.getDownloadUrl()
.addOnCompleteListener(task -> {
if (task.isSuccessful() && task.getResult() != null) {
String url = task.getResult().toString();
MyLogger.logMessage(TAG, url);
// here i have some logic to handle file
} else {
MyLogger.logError(TAG, "error getting url : " + task.getException());
emitter.onError(new Throwable(task.getException()));
}
});
它引发以下错误,应用程序崩溃。
2019-12-14 13:29:26.835 327-918/com E/StorageException: StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
2019-12-14 13:29:26.837 327-918/com E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@19.0.0:438)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@19.0.0:455)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@19.0.0:446)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@19.0.0:279)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@19.0.0:293)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@19.0.0:70)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@19.0.0:62)
at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@19.0.0:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
当我在主线程上执行相同的操作时,它会引发错误,但应用程序不会崩溃
我知道代码是完美的。
我还尝试实现不同的成功和失败侦听器,但没有发生相同的事情。
我知道该文件在该位置不存在。
我不在乎文件,但在处理错误。
即使我正确处理了错误,为什么应用也会崩溃?
这个问题已经被问到了,但是在任何地方都没有得到回答。