Skip to content

Remove jackson from UpdateMessageData#1938

Merged
SessionHero01 merged 6 commits intodevfrom
remove-jackson-sealed-data
Feb 16, 2026
Merged

Remove jackson from UpdateMessageData#1938
SessionHero01 merged 6 commits intodevfrom
remove-jackson-sealed-data

Conversation

@SessionHero01
Copy link
Collaborator

This unfortunately introduces some access to the singleton MessagingModuleConfiguration, however we will be moving away from UpdateMessageData soon.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request removes the Jackson dependency from UpdateMessageData and replaces it with kotlinx.serialization. The change involves updating the serialization annotations from Jackson's @JsonTypeInfo and @JsonSubTypes to kotlinx.serialization's @Serializable, @JsonClassDiscriminator, and @SerialName. To support this migration, a Json parameter is now required for the fromJSON and toJSON methods, which is passed via dependency injection in most places. Where dependency injection is not available (such as in MessageRecord.java and OpenGroupInvitationView.kt), the PR temporarily uses the MessagingModuleConfiguration singleton to access the Json instance, which is acknowledged as a temporary solution in the PR description.

Changes:

  • Migrated UpdateMessageData from Jackson to kotlinx.serialization with appropriate annotations
  • Updated all call sites to pass the Json instance parameter to serialization methods
  • Temporarily introduced singleton access in two locations where dependency injection is not available

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageData.kt Core migration: replaced Jackson annotations with kotlinx.serialization annotations and updated serialization methods to accept Json parameter
app/src/main/java/org/thoughtcrime/securesms/database/model/MessageRecord.java Updated to use singleton access to Json instance for deserialization
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/OpenGroupInvitationView.kt Updated to use singleton access to Json instance for deserialization
app/src/main/java/org/thoughtcrime/securesms/repository/DefaultConversationRepository.kt Updated to inject and pass Json parameter via dependency injection
app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt Updated to inject and pass Json parameter via dependency injection
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/ResendMessageUtilities.kt Updated to inject and pass Json parameter via dependency injection
app/src/main/java/org/session/libsession/messaging/messages/signal/OutgoingTextMessage.kt Updated to pass Json parameter to serialization method
app/src/main/java/org/session/libsession/messaging/messages/signal/IncomingTextMessage.kt Updated to pass Json parameter to serialization method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +156 to 161
fun fromJSON(json: Json, value: String): UpdateMessageData? {
return runCatching {
json.decodeFromString<UpdateMessageData>(value)
}.onFailure { Log.e(TAG, "Error decoding updateMessageData", it) }
.getOrNull()
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration from Jackson to kotlinx.serialization changes the JSON serialization implementation. While both use "@type" as the discriminator field, there may be subtle differences in formatting or behavior that could affect backward compatibility with existing messages in the database. Consider adding tests to verify that messages serialized with the old Jackson format can still be deserialized correctly with the new kotlinx.serialization implementation, or document if this has been verified.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
fun bind(message: MessageRecord, @ColorInt textColor: Int) {
// FIXME: This is a really weird approach...
val umd = UpdateMessageData.fromJSON(message.body)!!
val umd = UpdateMessageData.fromJSON(MessagingModuleConfiguration.shared.json, message.body)!!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to inject in the view, though it comes with being careful at the AndroidentryPoints along the way

@SessionHero01 SessionHero01 merged commit 666377f into dev Feb 16, 2026
5 checks passed
@SessionHero01 SessionHero01 deleted the remove-jackson-sealed-data branch February 16, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants