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

Update Serializer object to be an interface #219

Merged
merged 16 commits into from
Aug 27, 2024

Conversation

clr182
Copy link
Contributor

@clr182 clr182 commented Jul 14, 2024

Goal

Sometimes a non-serializable object can be passed as metadata, which can cause an error. As such the Serializer class should be converted to an interface so a user may use their own serializer which inherits from the Serializer interface.

Design

To allow users to develop their own Serializer for handling non-serializable data.

Changeset

Created an ISerializer class and changed the Serializer class to implement it.
By default this creates a default serializer if it is not specified in the configuration option.

Testing

Added test testCustomSerializer to ConfigurationTest.java which creates an anonymous class extending the DefaultSerializer and overwrites the WriteToStream method to write foo. Added an assertTrue call if the method has been called and added a call toassertEqual to confirm that the expected value is the same as the output.

@clr182 clr182 marked this pull request as draft July 14, 2024 12:05
@clr182 clr182 marked this pull request as ready for review July 15, 2024 07:57
@clr182 clr182 requested review from tomlongridge and lemnik July 15, 2024 07:58
@clr182 clr182 marked this pull request as draft July 18, 2024 12:15
@clr182 clr182 removed request for lemnik and tomlongridge July 18, 2024 12:15
@clr182 clr182 marked this pull request as ready for review July 26, 2024 13:34
bugsnag/src/main/java/com/bugsnag/Configuration.java Outdated Show resolved Hide resolved
@@ -95,6 +103,27 @@ public void testInvalidSessionEndpoint() {
assertEquals("http://sessions.example.com", getDeliveryEndpoint(config.sessionDelivery));
}

@Test
public void testSerializeObject() throws SerializationException {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel like the right level of test - the unit tests are testing that configuration is set right, rather than that what is provided does the right thing. So you could pass your own implementation of Serializer in that simply writes "foo" to the output stream and then validate that this is what you receive back; but we shouldn't compare JSON outputs.

bugsnag/src/main/java/com/bugsnag/Configuration.java Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -8,6 +8,8 @@

* Add a null check for `Severity` to the notify override method. [#214](https://github.com/bugsnag/bugsnag-java/pull/214)

* Add handling for non serializable object passed to metadata. [#219](https://github.com/bugsnag/bugsnag-java/pull/219)
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the PR description need updating for the amended approach - we're not handling non-serializable objects directly: just providing a way for people to do so if they provide their own serializer.

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR title and description are still out of date

@clr182 clr182 requested a review from tomlongridge July 29, 2024 10:29
@clr182 clr182 changed the title Plat 57 - non serialized object handling Update Serializer object to be an interface Jul 30, 2024
@clr182 clr182 requested a review from tomlongridge July 30, 2024 14:03
Co-authored-by: Tom Longridge <tom@bugsnag.com>
@clr182 clr182 requested a review from tomlongridge August 27, 2024 10:15
@clr182 clr182 merged commit 860035a into next Aug 27, 2024
1 check passed
@clr182 clr182 deleted the PLAT-57-non-serialized-object-handling branch August 27, 2024 16:35
@lemnik lemnik mentioned this pull request Aug 29, 2024
clr182 added a commit that referenced this pull request Aug 29, 2024
* (docs): update docs references from `master` to `main`

* (docs): switch build status badge to buildkite

* Update selector to accept only the major version

* Update Changelog

* update linting

* Added severity check (#214)

* added severity check

* fixed linting

* fixed linting v2

* added changelog entry

* Reverting changes

* update notify override with null check

* Update changelog

* Update Bugsnag.java

call notify override method on null severity

* add aopproxyutils dependancy and add handling in scheduledTaskConfig class (#218)

* add aopproxyutils dependancy and add handling in scheduledTaskConfig class

* fixed comment typo

* fixed import of aoputils

* added proxy testing

* fixed linting

* Updated tests

* updated tests

* update changelog

* moving createProxy method to util class

* update variable name

* reverting

* Update Serializer object to be an interface (#219)

* Adding non serializable metadata handling

* removed an unused import

* update feature

* update changelog

* Add serializeObject public method

* Fixed linting

* fixed tests

* Implemented Serializer interface

* update scenarios

* update changelog

* Changes based on feedback

* update tests

* updates based on reviews

* Update bugsnag/src/main/java/com/bugsnag/Configuration.java

Co-authored-by: Tom Longridge <tom@bugsnag.com>

* update config

---------

Co-authored-by: Tom Longridge <tom@bugsnag.com>

* v3.7.2

---------

Co-authored-by: Yousif Ahmed <yousif@bugsnag.com>
Co-authored-by: Yousif <74918474+yousif-bugsnag@users.noreply.github.com>
Co-authored-by: Tom Longridge <tom@bugsnag.com>
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