Skip to content

Commit 0dfe71c

Browse files
jeffrey-signalcody-signal
authored andcommitted
Fix crash when changing username on Android API < 24.
Basically, the crash was caused by using `Collections.unmodifiableList()`, which creates an `UnmodifiableCollection` wrapper around the original `List`. That `UnmodifiableCollection` wrapper contains methods that return `java.util.stream.Stream` – which was added in Java 8, but can be used on Android API < 24 through [desugaring](https://developer.android.com/studio/write/java8-support-table). _However_, it appears that when Jackson is using reflection to serialize `ReserveUsernameRequest`, it examines all of the methods of that class. This results in a `java.lang.NoClassDefFoundError: java.util.stream.Stream`, because the reflection is looking at the actual runtime `UnmodifiableCollection` class and not desugared code. As far as I can tell, that behavior is unavoidable and the only way to avoid this issue is to avoid using `Collections.unmodifiableList()` in classes that are serialized by Jackson on Android API < 24.
1 parent dc66da0 commit 0dfe71c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

libsignal-service/src/main/java/org/whispersystems/signalservice/internal/push/ReserveUsernameRequest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44

5-
import java.util.Collections;
65
import java.util.List;
76

87
public class ReserveUsernameRequest {
98
@JsonProperty
109
private List<String> usernameHashes;
1110

1211
public ReserveUsernameRequest(List<String> usernameHashes) {
13-
this.usernameHashes = Collections.unmodifiableList(usernameHashes);
12+
this.usernameHashes = usernameHashes;
1413
}
1514

1615
List<String> getUsernameHashes() {

0 commit comments

Comments
 (0)