realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Inconsistent order in annotation processing #7615

Closed jprinet closed 2 years ago

jprinet commented 2 years ago

How frequently does the bug occur?

Sometimes

Description

Annotation processing is not a fully consistent process given the usage of an unsorted Set to retrieve annotated elements

This randomly leads to some differences (usually using different JVM/OS) in the generated source code as RealmProxyMediatorGenerator is using this Set as a source of information: https://github.com/realm/realm-java/blob/e9a855f24292a43334ba3f30c61533313aba9ee1/realm/realm-annotations-processor/src/main/java/io/realm/processor/RealmProxyMediatorGenerator.kt#L40

This is fine syntax wise but prevent to benefit from Gradle remote cache as outputs are changing over time. Ordering the collection would solve this issue.

Stacktrace & log output

n/a

Can you reproduce the bug?

Yes, sometimes

Reproduction Steps

Having different JVM / OS can help to generate different orderings.

Version

10.9.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

MacOs and Linux

Build environment

n/a

cmelchior commented 2 years ago

Great catch, yes, that should be easy to fix. Thanks 👍

jprinet commented 2 years ago

I initiated a PR https://github.com/realm/realm-java/pull/7616

unit testing it is not trivial though