square / square/wire

Wire gson adapter cannot serialize an object with a Message field

Open
#1,907 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

If an object has a Message as a field attempting to serialize will fail with

java.lang.IllegalArgumentException: failed to access com.squareup.wire.Message#ADAPTER
coming out of ProtoAdapter.kt:215

Example failing class:

class LedgerEntry {
  final Message details;
  // ...
}

Failure was in java source but presumably the same would happen with .kt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ProtoAdapter.kt:215 and reproduce the failure with a Java class containing a Message field, such as the LedgerEntry example. Trace why serialization attempts to access Message#ADAPTER, then verify that the example serializes without the reported IllegalArgumentException and add coverage for the regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.