urbanairship / android-library

Urban Airship Android SDK
Other
109 stars 123 forks source link

PrivacyManager throws UnsupportedOperationException when starting airship without enabled features #241

Closed juschmitt closed 2 months ago

juschmitt commented 2 months ago

Preliminary Info

What Airship dependencies are you using?

com.urbanairship.android:urbanairship-core:18.1.0
com.urbanairship.android:urbanairship-fcm:18.1.0
com.urbanairship.android:urbanairship-automation:18.1.0
com.urbanairship.android:urbanairship-message-center:18.1.0

What are the versions of any relevant development tools you are using?

Report

What unexpected behavior are you seeing?

Creating the AirshipConfigOptions with .setEnabledFeatures() without providing any features to enable, throws an exception in airships PrivacyManager when it tries to combine all features.

We're getting a UnsupportedOperationException with the message Empty collection can't be reduced from here: https://github.com/urbanairship/android-library/blob/main/urbanairship-core/src/main/java/com/urbanairship/PrivacyManager.kt#L298-L301

I believe this started after PrivacyManager was converted to kotlin as the previous versions with the java implementation did not crash.

What is the expected behavior?

It doesn't throw an exception.

What are the steps to reproduce the unexpected behavior?

Initialise Airship with

AirshipConfigOptions.Builder()
.setEnabledFeatures()
// other options omitted as they are not relevant
.build()

Do you have logging for the issue?

java. lang UnsupportedOperationException: Empty collection can't be reduced. at
    com.urbanairship.PrivacyManager$Feature.combining$urbanairship_core_release(PrivacyManager.kt:526) at 
    com.urbanairship.PrivacyManager$Feature$Companion.combined(PrivacyManager.kt:487) at 
    com.urbanairship.PrivacyManager$Feature.combined(Unknown Source:2) at 
    com.urbanairship.AirshipConfigOptions$Builder.setEnabledFeatures(AirshipConfigOptions.java:1614) 
rlepinski commented 2 months ago

Thanks for the report, we will get a release out ASAP with the fix. For now you can use .setEnabledFeatures(PrivacyManager.Feature.NONE) as a workaround.

rlepinski commented 2 months ago

Fixed in 18.1.1