Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable SerializationFeature.FAIL_ON_EMPTY_BEANS in dataMapper #22

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

PetrHeinz
Copy link
Member

Avoids errors when objects without serializable properties is logged, eg.:

Error processing JSON data : No serializer found for class org.postgresql.core.v3.replication.V3ReplicationProtocol and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[1]->java.util.HashMap["args"]->org.postgresql.jdbc.PgConnection[1]->org.postgresql.jdbc.PgConnection["QueryExecutor"]->org.postgresql.core.v3.QueryExecutorImpl["ReplicationProtocol"])

Disabling it seems like a reasonable default in our case (better than dropping logs).


Tested with by logging a dummy object: logger.info("Logging empty beans.", new NoPropertiesBean());

    // A class with no properties that Jackson can serialize.
    // It doesn't have public fields, nor does it have any getter methods.
    private static class NoPropertiesBean {
        private int id; // Private field without a getter method.

        public NoPropertiesBean() {
            this.id = 1; // The constructor sets the value, but it's not accessible for Jackson.
        }
    }

Gets logged as an empty object {}:

image

@PetrHeinz PetrHeinz requested a review from curusarn April 4, 2024 14:56
Copy link
Contributor

@curusarn curusarn left a comment

Choose a reason for hiding this comment

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

Thanks!

@PetrHeinz PetrHeinz merged commit 3dc147c into main Apr 4, 2024
4 checks passed
@PetrHeinz PetrHeinz deleted the ph/disable-fail-on-empty-beans branch April 4, 2024 15:06
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