Skip to content

FileSortOrderByName crash : Comparison method violates its general contract! #17371

Closed

Description

@elbagers

⚠️ Before posting ⚠️

  • This is a bug, not a question or an enhancement.
  • I've searched for similar issues and didn't find a duplicate.
  • I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
  • I agree to follow Nextcloud's Code of Conduct.

Steps to reproduce

Cause of error

Exception in thread "DefaultDispatcher-worker-5" java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.TimSort.mergeHi(TimSort.java:903)
    at java.util.TimSort.mergeAt(TimSort.java:520)
    at java.util.TimSort.mergeForceCollapse(TimSort.java:461)
    at java.util.TimSort.sort(TimSort.java:254)
    at java.util.Arrays.sort(Arrays.java:1365)
    at java.util.ArrayList.sortRange(ArrayList.java:1834)
    at java.util.ArrayList.sort(ArrayList.java:1827)
    at java.util.Collections.sort(Collections.java:207)
    at kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42)
    at com.owncloud.android.utils.FileSortOrderByName.sortOnlyByName(FileSortOrderByName.kt:59)
    at com.owncloud.android.utils.FileSortOrderByName.sortCloudFiles(FileSortOrderByName.kt:32)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invokeSuspend(OCFileListAdapterHelper.kt:159)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invoke(OCFileListAdapterHelper.kt:8)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invoke(OCFileListAdapterHelper.kt:4)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:42)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:164)
    at kotlinx.coroutines.BuildersKt.withContext(dex-id-91442b47c60370bd28760623fdb31acd4f2c6112:1)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper.sortData(OCFileListAdapterHelper.kt:153)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper.prepareFileList(OCFileListAdapterHelper.kt:101)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$prepareFileList$2.invokeSuspend(OCFileListAdapterHelper.kt:20)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
    at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:266)
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:47)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)

App information

  • ID: com.nextcloud.client
  • Version: 340000190
  • Build flavor: gplay

Device information

  • Brand: samsung
  • Device: e3q
  • Model: SM-S928U1
  • Id: BP4A.251205.006
  • Product: e3quew

Firmware

  • SDK: 36
  • Release: 16
  • Incremental: S928U1UES6DZF2

Expected behaviour

Cause of error

Exception in thread "DefaultDispatcher-worker-5" java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.TimSort.mergeHi(TimSort.java:903)
    at java.util.TimSort.mergeAt(TimSort.java:520)
    at java.util.TimSort.mergeForceCollapse(TimSort.java:461)
    at java.util.TimSort.sort(TimSort.java:254)
    at java.util.Arrays.sort(Arrays.java:1365)
    at java.util.ArrayList.sortRange(ArrayList.java:1834)
    at java.util.ArrayList.sort(ArrayList.java:1827)
    at java.util.Collections.sort(Collections.java:207)
    at kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42)
    at com.owncloud.android.utils.FileSortOrderByName.sortOnlyByName(FileSortOrderByName.kt:59)
    at com.owncloud.android.utils.FileSortOrderByName.sortCloudFiles(FileSortOrderByName.kt:32)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invokeSuspend(OCFileListAdapterHelper.kt:159)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invoke(OCFileListAdapterHelper.kt:8)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invoke(OCFileListAdapterHelper.kt:4)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:42)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:164)
    at kotlinx.coroutines.BuildersKt.withContext(dex-id-91442b47c60370bd28760623fdb31acd4f2c6112:1)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper.sortData(OCFileListAdapterHelper.kt:153)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper.prepareFileList(OCFileListAdapterHelper.kt:101)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$prepareFileList$2.invokeSuspend(OCFileListAdapterHelper.kt:20)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
    at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:266)
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:47)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)

App information

  • ID: com.nextcloud.client
  • Version: 340000190
  • Build flavor: gplay

Device information

  • Brand: samsung
  • Device: e3q
  • Model: SM-S928U1
  • Id: BP4A.251205.006
  • Product: e3quew

Firmware

  • SDK: 36
  • Release: 16
  • Incremental: S928U1UES6DZF2

Actual behaviour

Cause of error

Exception in thread "DefaultDispatcher-worker-5" java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.TimSort.mergeHi(TimSort.java:903)
    at java.util.TimSort.mergeAt(TimSort.java:520)
    at java.util.TimSort.mergeForceCollapse(TimSort.java:461)
    at java.util.TimSort.sort(TimSort.java:254)
    at java.util.Arrays.sort(Arrays.java:1365)
    at java.util.ArrayList.sortRange(ArrayList.java:1834)
    at java.util.ArrayList.sort(ArrayList.java:1827)
    at java.util.Collections.sort(Collections.java:207)
    at kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42)
    at com.owncloud.android.utils.FileSortOrderByName.sortOnlyByName(FileSortOrderByName.kt:59)
    at com.owncloud.android.utils.FileSortOrderByName.sortCloudFiles(FileSortOrderByName.kt:32)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invokeSuspend(OCFileListAdapterHelper.kt:159)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invoke(OCFileListAdapterHelper.kt:8)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$sortData$2.invoke(OCFileListAdapterHelper.kt:4)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:42)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:164)
    at kotlinx.coroutines.BuildersKt.withContext(dex-id-91442b47c60370bd28760623fdb31acd4f2c6112:1)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper.sortData(OCFileListAdapterHelper.kt:153)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper.prepareFileList(OCFileListAdapterHelper.kt:101)
    at com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper$prepareFileList$2.invokeSuspend(OCFileListAdapterHelper.kt:20)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
    at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:266)
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:47)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)

App information

  • ID: com.nextcloud.client
  • Version: 340000190
  • Build flavor: gplay

Device information

  • Brand: samsung
  • Device: e3q
  • Model: SM-S928U1
  • Id: BP4A.251205.006
  • Product: e3quew

Firmware

  • SDK: 36
  • Release: 16
  • Incremental: S928U1UES6DZF2

Android version

16

Device brand and model

Samsung S24 Ultra

Stock or custom OS?

Stock

Nextcloud android app version

340000190

Nextcloud server version

00

Using a reverse proxy?

I don't know

Android logs

No response

Server error logs

Additional information

No response

Activity

  1. alihrhera commented on Jul 24, 2026

    @alihrhera

    Could you please provide a list of the file names associated with the crash, if available?

  2. elbagers commented on Jul 24, 2026

    @elbagers
    Author
  3. changed the title [-]Android bug[/-] [+]FileSortOrderByName crash : Comparison method violates its general contract![/+] on Jul 28, 2026
  4. linked a pull request that will close this issuefix(sort): alphanumeric comparator #17390on Jul 28, 2026
  5. alperozturk96 commented on Jul 28, 2026

    @alperozturk96
    Collaborator

    @elbagers Hey,

    Once the QA APK generated from PR could you please try?

    #17390

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions