Skip to content

use lazy initialization to resolve circular dependency between the DataFieldSerializer, DataTypeSerializer, and RowTypeSerializer classes that causes NPE for certain RowTypes like nested row type#3400

Open
umeshdangat wants to merge 2 commits into
apache:masterfrom
umeshdangat:use_lazy_init_type_serializers

Conversation

@umeshdangat

@umeshdangat umeshdangat commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

There is a circular dependency between the DataFieldSerializer, DataTypeSerializer, and RowTypeSerializer classes. This circular dependency can lead to incomplete initialization of the serializers, causing a NullPointerException when you attempt to use them.

Here's a breakdown of the problem:

  1. DataFieldSerializer has a DataTypeSerializer instance.
  2. DataTypeSerializer has a RowTypeSerializer instance.
  3. RowTypeSerializer has a ListSerializer<DataField> instance, which in turn uses DataFieldSerializer.

This circular dependency can cause the serializers to be in an incomplete state when they are first accessed, leading to the NullPointerException.

Code below is enough to re-create this NPE

        RowType innerMostRowType = RowType.of(DataTypes.BIGINT());
        RowType outerRowType = RowType.of(
                DataTypes.ROW(DataTypes.FIELD("outerRow", innerMostRowType)));

        DataTypeSerializer serializer = new DataTypeSerializer();


        assertNotNull(RowTypeSerializer.INSTANCE, "RowTypeSerializer.INSTANCE is null");
        RowType copiedRow = (RowType) serializer.copy(outerRowType);

…ataFieldSerializer`, `DataTypeSerializer`, and `RowTypeSerializer` classes that causes NPE for certain RowTypes like nested row type
@github-actions

github-actions Bot commented Aug 7, 2024

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity for 60 days. It will be closed in 30 days if no further activity occurs.

@github-actions github-actions Bot added Stale and removed Stale labels Aug 7, 2024
@github-actions

github-actions Bot commented Oct 7, 2024

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity for 60 days. It will be closed in 30 days if no further activity occurs.

@github-actions github-actions Bot added the Stale label Oct 7, 2024
@github-actions

github-actions Bot commented Nov 7, 2024

Copy link
Copy Markdown

This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.

@github-actions github-actions Bot closed this Nov 7, 2024
@yuxiqian

Copy link
Copy Markdown
Member

Could @leonardBang please reopen this?

@leonardBang leonardBang reopened this Nov 14, 2024
@umeshdangat

Copy link
Copy Markdown
Contributor Author

PR #3434 also has this change! Merging that should enable us to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants