Backend Development 8 min read

Handling Non-Standard Collection Types in Dubbo RPC with Protostuff Serialization

When Dubbo RPC uses Protostuff serialization, DTO fields declared with ambiguous types that contain non‑standard collections such as subList results can trigger ClassNotFound or null errors during deserialization, so converting these to regular JDK collections (or switching to a more tolerant format like Hessian2/JSON) restores stability.

DeWu Technology
DeWu Technology
DeWu Technology
Handling Non-Standard Collection Types in Dubbo RPC with Protostuff Serialization

This article examines a common Dubbo RPC + Protostuff serialization issue where DTO fields with ambiguous types assigned non-standard collection types cause null or error responses.

The problem occurs when:

1. The interface uses Dubbo RPC.

2. The interface uses Protostuff serialization.

3. A DTO field is declared with an ambiguous type (e.g., Object, List).

4. That field is assigned a non-standard collection type such as the result of ArrayList#subList , Apache Commons FastArrayList.SubList#subList , or Guava Lists#transform / Lists#partition .

Protostuff adds type hints (fully‑qualified class names) to the serialized byte stream, but during deserialization the remote side may fail if the class does not exist in its classpath or cannot be instantiated via reflection (e.g., inner classes, static private classes). This leads to ClassNotFoundError, NoSuchMethodException, or null values.

Solutions include:

• Switching to a more robust serialization format like Hessian2 or JSON after full regression testing.

• Converting non‑standard collections to standard ones before putting them into the DTO, for example:

ArrayList list = Lists.newArrayList(1,2,3); List obj3 = list.subList(1,2); List obj4 = new ArrayList<>(obj3);

Similar conversion patterns apply to Apache Commons Lang3 and Guava utilities.

By ensuring only standard JDK collection types are transferred, the Dubbo‑Protostuff pipeline remains stable and avoids unexpected null/error responses.

backendJavaDTODubboNon-standard collectionsProtostuffSerialization
DeWu Technology
Written by

DeWu Technology

A platform for sharing and discussing tech knowledge, guiding you toward the cloud of technology.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.