[
https://issues.apache.org/jira/browse/BEAM-10265?focusedWorklogId=765070&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765070
]
ASF GitHub Bot logged work on BEAM-10265:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 02/May/22 18:05
Start Date: 02/May/22 18:05
Worklog Time Spent: 10m
Work Description: TheNeuralBit commented on code in PR #17477:
URL: https://github.com/apache/beam/pull/17477#discussion_r863064197
##########
sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java:
##########
@@ -139,6 +140,16 @@ class ProtoSchemaTranslator {
/** Option prefix for options on fields. */
public static final String SCHEMA_OPTION_FIELD_PREFIX =
"beam:option:proto:field:";
+ /**
+ * A HashMap containing the non-primitive schemas within another schema, to
prevent circular
+ * references.
Review Comment:
Could you document that this Map stores a sentinel value representing
"in-progress" schemas (null or empty schema).
##########
sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java:
##########
@@ -139,6 +140,16 @@ class ProtoSchemaTranslator {
/** Option prefix for options on fields. */
public static final String SCHEMA_OPTION_FIELD_PREFIX =
"beam:option:proto:field:";
+ /**
+ * A HashMap containing the non-primitive schemas within another schema, to
prevent circular
+ * references.
+ */
+ private static Map<Descriptors.Descriptor, Schema> alreadyVisitedSchemas =
+ new HashMap<Descriptors.Descriptor, Schema>();
Review Comment:
I think an alternative fix for this would be to annotate all values as
Nullable, e.g.:
```suggestion
new HashMap<Descriptors.Descriptor, @Nullable Schema>();
```
(and `@Nullable Schema existingSchema` below)
Issue Time Tracking
-------------------
Worklog Id: (was: 765070)
Time Spent: 5h 40m (was: 5.5h)
> GetterBasedSchemaProvider#schemaFor stack overflows when given a recursive
> schema
> ---------------------------------------------------------------------------------
>
> Key: BEAM-10265
> URL: https://issues.apache.org/jira/browse/BEAM-10265
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Affects Versions: 2.21.0, 2.22.0
> Reporter: Reza ardeshir rokni
> Assignee: Andrei Gurau
> Priority: P3
> Labels: Clarified, starter
> Time Spent: 5h 40m
> Remaining Estimate: 0h
>
> Proto:
> message TSFoo {
> string a = 1;
> string b = 2;
> TSFoo theOlderMe = 3;
> }
> new ProtoMessageSchema().schemaFor(TypeDescriptor.of(Foo.TSFoo.class));
> Causes a stackoverflow.
>
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)