Skip to content

Bael 7805 how to fix json io exception failed making field property accessible in gson - #19293

Open
MBuczkowski2025 wants to merge 15 commits into
eugenp:masterfrom
MBuczkowski2025:BAEL-7805_How_to_fix_JsonIOException_Failed_making_field_property_accessible_in_Gson
Open

Bael 7805 how to fix json io exception failed making field property accessible in gson#19293
MBuczkowski2025 wants to merge 15 commits into
eugenp:masterfrom
MBuczkowski2025:BAEL-7805_How_to_fix_JsonIOException_Failed_making_field_property_accessible_in_Gson

Conversation

@MBuczkowski2025

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread json-modules/gson-4/pom.xml Outdated
Comment thread json-modules/gson-4/pom.xml Outdated
Comment thread json-modules/gson-4/gson-module/src/test/java/gson/exception/ModularGsonTest.java Outdated
Comment thread json-modules/gson-4/gson-module/pom.xml Outdated
Comment thread json-modules/gson-4/pom.xml Outdated
Comment thread json-modules/gson-4/gson-module-opens/pom.xml
Comment thread json-modules/gson-4/gson-module-opens/src/main/java/module-info.java Outdated

@theangrydev theangrydev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor formatting points remaining, otherwise done with PR

Comment on lines +15 to +38
@Test
void givenModularAndExportedPackage_whenDeserializingPojo_thenJsonIOException() {
String json = """
{
"name": "Java Conference",
"numberOfParticipants": 150
}
""";
Gson gson = new Gson();

assertThrows(JsonIOException.class, () -> {
gson.fromJson(json, ConferencePojo.class);
});
}

@Test
void givenModularAndExportedPackage_whenDeserializingRecord_thenSuccess() {
String json = """
{
"name": "Java Conference",
"numberOfParticipants": 150
}
""";
Gson gson = new Gson();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still formatting things differently between tests - can we align the formatting to be consistent throughout - it's distracting for a reader to see different formatting and have to try and figure out if there's any real difference or just a formatting difference

Comment on lines +19 to +21
name:"Java Conference",
numberOfParticipants:500,
conferenceStart:{"year":2026,"month":8,"day":17}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing "" around the fields here - this is only working by accident because Gson has lenient parsing by default

And please normalise the formatting to the standard indentation style

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants