Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,31 @@ private ProtobufField _findAndResolve(FieldElement nativeField, String typeStr)
if (nativeMt != null) {
return new ProtobufField(nativeField, resolve(this, nativeMt));
}
return null;
// [dataformats-binary#73] Handle dot-notation references to nested message types
// (e.g. "OuterType.InnerType")
return _findDottedType(nativeField, typeStr);
}

/**
* Try to resolve a dot-notation type reference (e.g. {@code "OuterType.InnerType"})
* by navigating the message type hierarchy declared at this scope level.
*/
private ProtobufField _findDottedType(FieldElement nativeField, String typeStr)
{
int dotIx = typeStr.indexOf('.');
if (dotIx <= 0) {
return null;
}
String outerName = typeStr.substring(0, dotIx);
String innerPath = typeStr.substring(dotIx + 1);
MessageElement outerMsg = _declaredMessageTypes.get(outerName);
if (outerMsg == null) {
return null;
}
// Create a resolver in the context of the outer type and recursively
// resolve the remaining path (handles arbitrary nesting depth)
TypeResolver outerResolver = TypeResolver.construct(this, outerName, outerMsg.nestedElements());
return outerResolver._findAndResolve(nativeField, innerPath);
}

private StringBuilder _knownEnums(StringBuilder sb) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
package com.fasterxml.jackson.dataformat.protobuf.tofix;
package com.fasterxml.jackson.dataformat.protobuf.schema;

import java.io.StringReader;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper;
import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase;
import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema;
import com.fasterxml.jackson.dataformat.protobuf.testutil.failure.JacksonTestFailureExpected;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class GenerateNestedType73Test extends ProtobufTestBase
// [dataformats-binary#73]
public class NestedTypeRef73Test extends ProtobufTestBase
{
/*
/**********************************************************
/* Test methods
/**********************************************************
*/

final ProtobufMapper MAPPER = new ProtobufMapper();

// [dataformats-binary#68]
@JacksonTestFailureExpected
// [dataformats-binary#73]: dot-notation reference to a nested message type
@Test
public void testNestedTypes() throws Exception
public void testNestedTypeRefViaRootType() throws Exception
{
final String SCHEMA_STR =
" package mypackage;\n"
Expand Down
2 changes: 2 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Kenji Noguchi (knoguchi@github)

* Reported #70 (protobuf), contributed fix: Can't deserialize packed repeated field
(2.8.9)
* Reported #73: (protobuf) Cannot resolve inner types in protoc definitions
(2.21.5)

marsqing@github

Expand Down
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Active maintainers:
=== Releases ===
------------------------------------------------------------------------

2.21.5 (not yet released)

#73: (protobuf) Cannot resolve inner types in protoc definitions
(reported by Kenji N)

2.21.4 (28-May-2026)

#691: (cbor) Add parameterized tests covering all ASCII-optimization exit paths in CBORParser
Expand Down