-
Notifications
You must be signed in to change notification settings - Fork 34
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
Conversation
bugsnag/src/main/java/com/bugsnag/serialization/ISerializer.java
Outdated
Show resolved
Hide resolved
bugsnag/src/main/java/com/bugsnag/serialization/ISerializer.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 { |
There was a problem hiding this comment.
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.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
bugsnag/src/main/java/com/bugsnag/serialization/Serializer.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Tom Longridge <tom@bugsnag.com>
* (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>
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
toConfigurationTest.java
which creates an anonymous class extending theDefaultSerializer
and overwrites theWriteToStream
method to writefoo
. Added anassertTrue
call if the method has been called and added a call toassertEqual
to confirm that the expected value is the same as the output.