square / square/wire

Migration from 1.8 to 2.0, question about encoding in a shared class

Open
#1,205 0 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

More of a question than an issue.

Usage in multiple places is as follows:

A_Message message = ....
send(message)

or

B_Message message = ...
send(message)

Implementation of send() is as follows:
Question: How do I get encoded byte array from the message here? With 1.8, I could simply use message.toByteArray()

void send(Message<?,?> message)
    ::
    // doesn't work because message is not of type A_Message or B_Message
    ProtoAdapter.get(message).encode(message); 
    ::

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

The question centers on the shared send(Message message) method and the ProtoAdapter.get(message).encode(message) call, but names no repository files or tests. Start by locating those entry points and the 1.8-to-2.0 migration guidance; done would be documented, confirmed instructions for obtaining encoded bytes from the shared message type.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.