mapbox-java icon indicating copy to clipboard operation
mapbox-java copied to clipboard

Fix mutable issues in AutoValue classes

Open cammace opened this issue 8 years ago • 7 comments

We are currently using primitive arrays in some cases inside our auto value classes which are potentially mutable, we should look further into this and resolve the issue or suppress the warnings.

cammace avatar Oct 07 '17 19:10 cammace

@cammace was this fixed with the latest 3.0.0? Not quite sure what this means in terms of AutoValue

danesfeder avatar Dec 18 '17 18:12 danesfeder

Hey @cammace could you clarify what this means in terms of AutoValue when you have a chance?

Guardiola31337 avatar Mar 22 '18 21:03 Guardiola31337

resolve the issue or suppress the warnings

In our model classes which use AutoValue, some of the methods use arrays which are by nature mutable in Java after the instance is built. To resolve this issue you have two choices, inside the Builder#build method, convert to an immutable list (I think there's a Collections method for this but can't remember off the top of my head) or you can simply suppress the warning so, during compile time, the warning isn't thrown. Check out the AutoValue docs for more info.

See https://github.com/google/auto/blob/master/value/userguide/howto.md#mutable_property

cammace avatar Apr 17 '18 15:04 cammace

Per Kotlin migration we don't use AutoValue anymore.

Closing here as not actionable.

cc @kmadsen

Guardiola31337 avatar Jun 01 '20 18:06 Guardiola31337

The directions api objects still have mutable lists. Another option is to move this ticket to mapbox-java

For example, you can change a BannerText list item because they have mutable lists

val bannerComponents = bannerText?.components()
bannerComponents?.set(0, bannerComponents[0].toBuilder()
    .imageUrl(null)
    .build())

kmadsen avatar Jun 03 '20 13:06 kmadsen

Another option is to move this ticket to mapbox-java

👍

Guardiola31337 avatar Jun 03 '20 13:06 Guardiola31337

Re-opened @kmadsen

Guardiola31337 avatar Jun 03 '20 13:06 Guardiola31337