Skip to content

Conversation

@alperozturk96
Copy link
Collaborator

@alperozturk96 alperozturk96 commented Oct 22, 2025

Issue

When nothing changes, API processes empty Reader then it is causing JsonSyntaxException.

SSO PR: nextcloud/Android-SingleSignOn#910

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
See https://github.com/google/gson/blob/main/Troubleshooting.md#unexpected-json-structure
	at com.google.gson.Gson.fromJson(Gson.java:1381)
	at com.google.gson.Gson.fromJson(Gson.java:1259)
	at com.google.gson.Gson.fromJson(Gson.java:1227)
	at com.nextcloud.android.sso.api.NextcloudAPI.convertStreamToTargetEntity(NextcloudAPI.java:136)
	at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$0(NextcloudAPI.java:98)
	at com.nextcloud.android.sso.api.NextcloudAPI.$r8$lambda$af7W9mq2B0ZrhVJwZd-ibFp8T3Y(Unknown Source:0)
	at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda2.subscribe(D8$$SyntheticClass:0)
	at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31)
	at io.reactivex.Observable.subscribe(Observable.java:12284)
	at io.reactivex.internal.operators.observable.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:31)
	at io.reactivex.Maybe.subscribe(Maybe.java:4290)
	at io.reactivex.Maybe.blockingGet(Maybe.java:2320)
	at io.reactivex.Observable.blockingSingle(Observable.java:5381)
	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pullRemoteChanges(NotesServerSyncTask.java:229)
	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:101)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:520)
	at java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1154)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:652)
	at java.lang.Thread.run(Thread.java:1563)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
See https://github.com/google/gson/blob/main/Troubleshooting.md#unexpected-json-structure
	at com.google.gson.stream.JsonReader.unexpectedTokenError(JsonReader.java:1831)
	at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:470)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:64)
	at com.google.gson.Gson.fromJson(Gson.java:1358)
	... 19 more

Changes

Ignores empty response

Signed-off-by: alperozturk <alper_ozturk@proton.me>

# Conflicts:
#	app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java
#	app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesServerSyncTask.java
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
@github-actions
Copy link
Contributor

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/2883.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@alperozturk96
Copy link
Collaborator Author

/backport to stable-4.5

@alperozturk96 alperozturk96 marked this pull request as draft October 28, 2025 09:14
@alperozturk96
Copy link
Collaborator Author

Android Files application is responsible for handling 304 response, thus this PR is not valid anymore.

Note

Sometimes the loading indicator in the Notes app gets stuck due to the current behavior of InputStreamBinder in the Files application and how it is handled in the SSO library. This needs to be addressed in a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants