nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.27k stars 1.77k forks source link

`java.lang.NullPointerException` in `OfflineSyncWork.checkEtagChanged` line `140` #11342

Open hasezoey opened 1 year ago

hasezoey commented 1 year ago

⚠️ Before posting ⚠️

Steps to reproduce

it happens in a background task

Expected behaviour

probably no error

Actual behaviour

a error is logged

02-02 13:07:33.077  3991  4038 E CheckEtagRemoteOperation: Error while retrieving eTag
02-02 13:07:33.077  3991  4038 D OfflineSyncJob: /: eTag changed
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper: Work [ id=1978cd15-2514-4729-9d89-d67a22ebbfc0, tags={ timestamp:1675177395832, com.nextcloud.client.jobs.OfflineSyncWork, *, name:periodic_offline_sync } ] failed because it threw an exception/error
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.get(int)' on a null object reference
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at java.lang.Thread.run(Thread.java:1012)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.get(int)' on a null object reference
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at com.nextcloud.client.jobs.OfflineSyncWork.checkEtagChanged(OfflineSyncWork.kt:140)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at com.nextcloud.client.jobs.OfflineSyncWork.recursive(OfflineSyncWork.kt:79)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at com.nextcloud.client.jobs.OfflineSyncWork.doWork(OfflineSyncWork.kt:64)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  at androidx.work.Worker$1.run(Worker.java:86)
02-02 13:07:33.079  3991  4011 E WM-WorkerWrapper:  ... 3 more
02-02 13:07:33.080  3991  4011 I WM-WorkerWrapper: Worker result FAILURE for Work [ id=1978cd15-2514-4729-9d89-d67a22ebbfc0, tags={ timestamp:1675177395832, com.nextcloud.client.jobs.OfflineSyncWork, *, name:periodic_offline_sync } ]

Android version

13

Device brand and model

OnePlus 9 Pro

Stock or custom OS?

Custom (explain in "additional information")

Nextcloud android app version

3.23.1

Nextcloud server version

None (error happened when server is not online)

Using a reverse proxy?

Yes

Android logs

logcatOutput.txt Note: log has been edited to remove references to actual server / ip's (and also somewhat personal data like directory names)

Server error logs

None (no server was running)

Additional information

i had noticed this error while investigating something unrelated to nextcloud, and i am reporting it because this error does not seem like it should be happening

probably: https://github.com/nextcloud/android/blob/8cc3bd1d415e2f602039fb47c1ad8b81de7cf592/app/src/main/java/com/nextcloud/client/jobs/OfflineSyncWork.kt#L140

Custom (explain in "additional information")

LineageOS 20 (20.0-20230131)

joshtrichards commented 2 months ago

This may have since been fixed via #12794.

Are you still experiencing this in newer versions?

hasezoey commented 1 month ago

sorry for the late response, i didnt have the server offline of a bit.

anyway, i could not see the error in a generic background task (without opening the app) anymore, instead there were some other errors which seemed more appropriate:

31611  2079 E GetMethod: java.net.ConnectException: Failed to connect to nextcloud.server/1.1.1.1:443
31611  2079 E GetMethod:     at okhttp3.internal.connection.ConnectPlan.connectSocket(ConnectPlan.kt:267)
31611  2079 E GetMethod:     at okhttp3.internal.connection.ConnectPlan.connectTcp(ConnectPlan.kt:136)
31611  2079 E GetMethod:     at okhttp3.internal.connection.FastFallbackExchangeFinder$launchTcpConnect$1.runOnce(FastFallbackExchangeFinder.kt:138)
31611  2079 E GetMethod:     at okhttp3.internal.concurrent.TaskRunner.runTask(TaskRunner.kt:122)
31611  2079 E GetMethod:     at okhttp3.internal.concurrent.TaskRunner.access$runTask(TaskRunner.kt:44)
31611  2079 E GetMethod:     at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:71)
31611  2079 E GetMethod:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
31611  2079 E GetMethod:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
31611  2079 E GetMethod:     at java.lang.Thread.run(Thread.java:1012)
31611  2079 E GetMethod: Caused by: java.net.ConnectException: failed to connect to nextcloud.server/1.1.1.1 (port 443) from /1.1.1.2 (port 40236) after 10000ms: isConnected failed: EHOSTUNREACH (No route to host)
31611  2079 E GetMethod:     at libcore.io.IoBridge.isConnected(IoBridge.java:347)
31611  2079 E GetMethod:     at libcore.io.IoBridge.connectErrno(IoBridge.java:237)
31611  2079 E GetMethod:     at libcore.io.IoBridge.connect(IoBridge.java:179)
31611  2079 E GetMethod:     at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
31611  2079 E GetMethod:     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
31611  2079 E GetMethod:     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
31611  2079 E GetMethod:     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
31611  2079 E GetMethod:     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
31611  2079 E GetMethod:     at java.net.Socket.connect(Socket.java:646)
31611  2079 E GetMethod:     at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:140)
31611  2079 E GetMethod:     at okhttp3.internal.connection.ConnectPlan.connectSocket(ConnectPlan.kt:265)
31611  2079 E GetMethod:     ... 8 more
31611  2079 E GetMethod: Caused by: android.system.ErrnoException: isConnected failed: EHOSTUNREACH (No route to host)
31611  2079 E GetMethod:     at libcore.io.IoBridge.isConnected(IoBridge.java:334)
31611  2079 E GetMethod:     ... 18 more
31611  2079 W ConnectivityServiceImpl: isInternetWalled(): Failed to GET /index.php/204, assuming connectivity is impaired

(ips and dns redacted)

but when opening the app (and waiting for a bit until it says "server unreachable" just to make sure), the following can still be observed like the original issue:

31611 31711 E CheckEtagRemoteOperation: Error while retrieving eTag
31611 31711 D OfflineSyncJob: /: eTag changed
31611 31687 E WM-WorkerWrapper: Work [ id=1978cd15-2514-4729-9d89-d67a22ebbfc0, tags={ timestamp:1675177395832, com.nextcloud.client.jobs.OfflineSyncWork, *, name:periodic_offline_sync } ] failed because it threw an exception/error
31611 31687 E WM-WorkerWrapper: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.get(int)' on a null object reference
31611 31687 E WM-WorkerWrapper:      at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:515)
31611 31687 E WM-WorkerWrapper:      at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:474)
31611 31687 E WM-WorkerWrapper:      at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:316)
31611 31687 E WM-WorkerWrapper:      at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
31611 31687 E WM-WorkerWrapper:      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
31611 31687 E WM-WorkerWrapper:      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
31611 31687 E WM-WorkerWrapper:      at java.lang.Thread.run(Thread.java:1012)
31611 31687 E WM-WorkerWrapper: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.get(int)' on a null object reference
31611 31687 E WM-WorkerWrapper:      at com.nextcloud.client.jobs.OfflineSyncWork.checkEtagChanged(OfflineSyncWork.kt:131)
31611 31687 E WM-WorkerWrapper:      at com.nextcloud.client.jobs.OfflineSyncWork.recursive(OfflineSyncWork.kt:68)
31611 31687 E WM-WorkerWrapper:      at com.nextcloud.client.jobs.OfflineSyncWork.doWork(OfflineSyncWork.kt:53)
31611 31687 E WM-WorkerWrapper:      at androidx.work.Worker$1.run(Worker.java:82)
31611 31687 E WM-WorkerWrapper:      ... 3 more
31611 31687 I WM-WorkerWrapper: Worker result FAILURE for Work [ id=1978cd15-2514-4729-9d89-d67a22ebbfc0, tags={ timestamp:1675177395832, com.nextcloud.client.jobs.OfflineSyncWork, *, name:periodic_offline_sync } 

(quick link to line)

App version 3.29.2