From 8663402356563d0e9cce52a0c68cd24ecdbed126 Mon Sep 17 00:00:00 2001 From: Christian Rafferty <38156512+clr182@users.noreply.github.com> Date: Thu, 29 Aug 2024 09:56:51 +0100 Subject: [PATCH] Release/v3.7.2 (#222) * (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 * update config --------- Co-authored-by: Tom Longridge * v3.7.2 --------- Co-authored-by: Yousif Ahmed Co-authored-by: Yousif <74918474+yousif-bugsnag@users.noreply.github.com> Co-authored-by: Tom Longridge --- CHANGELOG.md | 16 +++++++++ CONTRIBUTING.md | 8 ++--- README.md | 4 +-- bugsnag-spring/build.gradle | 9 +++-- .../com/bugsnag/BugsnagImportSelector.java | 7 ++-- .../bugsnag/ScheduledTaskConfiguration.java | 14 ++++++-- .../ScheduledTaskConfigurationTest.java | 29 +++++++++++++++- .../ScheduledTaskConfigurationTest.java | 28 +++++++++++++++ .../src/main/java/com/bugsnag/Bugsnag.java | 3 ++ .../main/java/com/bugsnag/Configuration.java | 4 +-- .../src/main/java/com/bugsnag/Notifier.java | 2 +- .../serialization/DefaultSerializer.java | 33 ++++++++++++++++++ .../com/bugsnag/serialization/Serializer.java | 34 ++++--------------- .../java/com/bugsnag/ConfigurationTest.java | 27 +++++++++++++++ .../com/bugsnag/HandledStatePayloadTest.java | 4 +-- features/meta_data.feature | 2 -- gradle.properties | 2 +- 17 files changed, 177 insertions(+), 49 deletions(-) create mode 100644 bugsnag/src/main/java/com/bugsnag/serialization/DefaultSerializer.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 9add0b5e..c78839dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 3.7.2 (2024-08-28) + +### Changed + +* Add a null check for `Severity` to the notify override method. [#214](https://github.com/bugsnag/bugsnag-java/pull/214) + +* Created Serializer interface, allowing for implementation of a custom serializer. [#219](https://github.com/bugsnag/bugsnag-java/pull/219) + +* Updated ScheduleTaskConfiguration configureTask method to properly handle wrapped/proxied objects. [#218](https://github.com/bugsnag/bugsnag-java/pull/218) + +### Bug Fixes + +* Update `BugsnagImportSelector` to allow major versions that do not have a minor version. + fixes [issue #211](https://github.com/bugsnag/bugsnag-java/issues/211). + [#213](https://github.com/bugsnag/bugsnag-java/pull/213) + ## 3.7.1 (2023-10-25) * Restore `BugsnagServletContainerInitializer` and `BugsnagServletRequestListener` to the `com.bugsnag.servlet` package. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a95dca3f..e4720bf0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,15 +122,15 @@ To start a release: - `./gradlew -Preleasing=true clean publishAllPublicationsToSonatypeRepository` - Verify that the artefacts are uploaded to sonatype - ensure that JARs, POMs and JAVADOCs are present for each module. - Test the Sonatype artefacts in the example app by adding the newly created 'combugsnag-XXXX' repository to the build.gradle: maven {url "https://oss.sonatype.org/service/local/repositories/combugsnag-XXXX/content/"} -- Once you are happy, make a PR from your release branch to `master` entitled `Release vX.Y.Z` +- Once you are happy, make a PR from your release branch to `main` entitled `Release vX.Y.Z` - Get the release PR reviewed – all code changes should have been reviewed already, this should be a review of the integration of all changes to be shipped and the changelog - Once merged: - - Pull the latest changes (checking out `master` if necessary) + - Pull the latest changes (checking out `main` if necessary) - Create a release build and upload to sonatype: - `./gradlew -Preleasing=true clean publishAllPublicationsToSonatypeRepository` - Release to GitHub: - - [ ] Create *and tag* the release from `master` on [GitHub Releases](https://github.com/bugsnag/bugsnag-android/releases), attaching the changelog entry and build artifacts - - Checkout `master` and pull the latest changes + - [ ] Create *and tag* the release from `main` on [GitHub Releases](https://github.com/bugsnag/bugsnag-android/releases), attaching the changelog entry and build artifacts + - Checkout `main` and pull the latest changes - "Promote" the release build on Maven Central: - Go to the [sonatype open source dashboard](https://oss.sonatype.org/index.html#stagingRepositories) - Click the search box at the top right, and type “com.bugsnag” diff --git a/README.md b/README.md index 8b38dabd..5d8c0a6f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Bugsnag exception reporter for Java [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://docs.bugsnag.com/platforms/java) -[![Build status](https://travis-ci.org/bugsnag/bugsnag-java.svg?branch=master)](https://travis-ci.org/bugsnag/bugsnag-java) +[![Build status](https://badge.buildkite.com/de087a23152718c7d33b0ae7f566a940a92fb9d92becdb61a3.svg?branch=main)](https://buildkite.com/bugsnag/bugsnag-java) The Bugsnag exception reporter for Java automatically detects and reports errors and exceptions in your Java code. Learn more about [reporting Java exceptions](https://www.bugsnag.com/platforms/java/) with Bugsnag. @@ -35,7 +35,7 @@ The Bugsnag exception reporter for Java automatically detects and reports errors ## Contributing All contributors are welcome! For information on how to build, test, and release -`bugsnag-java`, see our [contributing guide](https://github.com/bugsnag/bugsnag-java/blob/master/CONTRIBUTING.md). +`bugsnag-java`, see our [contributing guide](https://github.com/bugsnag/bugsnag-java/blob/main/CONTRIBUTING.md). ## License diff --git a/bugsnag-spring/build.gradle b/bugsnag-spring/build.gradle index b8a9fb62..379cc762 100644 --- a/bugsnag-spring/build.gradle +++ b/bugsnag-spring/build.gradle @@ -134,27 +134,32 @@ dependencies { compileJavax "javax.servlet:javax.servlet-api:${javaxServletApiVersion}" compileJavax "org.springframework:spring-webmvc:${javaxSpringVersion}" compileJavax "org.springframework.boot:spring-boot:${javaxSpringBootVersion}" + compileJavax "org.springframework:spring-aop:${javaxSpringVersion}" compileJakarta "jakarta.servlet:jakarta.servlet-api:${jakartaServletApiVersion}" compileJakarta "org.springframework:spring-webmvc:${jakartaSpringVersion}" compileJakarta "org.springframework.boot:spring-boot:${jakartaSpringBootVersion}" + compileJakarta "org.springframework:spring-aop:${jakartaSpringVersion}" + commonTestImplementation project(':bugsnag').sourceSets.test.output commonTestImplementation project(':bugsnag') commonTestImplementation "junit:junit:${junitVersion}" - + commonTestCompileOnly "org.mockito:mockito-core:2.10.0" - + jakartaTestImplementation "org.mockito:mockito-core:${mockitoVersion}" jakartaTestImplementation "jakarta.servlet:jakarta.servlet-api:${jakartaServletApiVersion}" jakartaTestImplementation "org.springframework.boot:spring-boot-starter-test:${jakartaSpringBootVersion}" jakartaTestImplementation "org.springframework.boot:spring-boot-starter-web:${jakartaSpringBootVersion}" + jakartaTestImplementation "org.springframework:spring-aop:${jakartaSpringVersion}" javaxTestImplementation "org.mockito:mockito-core:2.10.0" javaxTestImplementation "javax.servlet:javax.servlet-api:${javaxServletApiVersion}" javaxTestImplementation "org.springframework.boot:spring-boot-starter-test:${javaxSpringBootVersion}" javaxTestImplementation "org.springframework.boot:spring-boot-starter-web:${javaxSpringBootVersion}" + javaxTestImplementation "org.springframework:spring-aop:${javaxSpringVersion}" } dependencies { diff --git a/bugsnag-spring/src/common/java/com/bugsnag/BugsnagImportSelector.java b/bugsnag-spring/src/common/java/com/bugsnag/BugsnagImportSelector.java index 6d6e91da..36f10e1a 100644 --- a/bugsnag-spring/src/common/java/com/bugsnag/BugsnagImportSelector.java +++ b/bugsnag-spring/src/common/java/com/bugsnag/BugsnagImportSelector.java @@ -40,11 +40,14 @@ private static int getMajorVersion(String version) { return 0; } int firstDot = version.indexOf("."); + String majorVersion; + if (firstDot == -1) { - return 0; + majorVersion = version; + } else { + majorVersion = version.substring(0, firstDot); } - String majorVersion = version.substring(0, firstDot); try { return Integer.parseInt(majorVersion); } catch (NumberFormatException nfe) { diff --git a/bugsnag-spring/src/common/java/com/bugsnag/ScheduledTaskConfiguration.java b/bugsnag-spring/src/common/java/com/bugsnag/ScheduledTaskConfiguration.java index 49d1d366..6c9718a9 100644 --- a/bugsnag-spring/src/common/java/com/bugsnag/ScheduledTaskConfiguration.java +++ b/bugsnag-spring/src/common/java/com/bugsnag/ScheduledTaskConfiguration.java @@ -2,6 +2,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.aop.framework.AopProxyUtils; +import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.TaskScheduler; @@ -9,6 +11,7 @@ import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.config.ScheduledTaskRegistrar; + import org.springframework.util.ErrorHandler; import java.lang.reflect.Field; @@ -49,10 +52,17 @@ public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { ? registrarScheduler : beanLocator.resolveTaskScheduler(); if (taskScheduler != null) { + //check if taskSchedular is a proxy + if (AopUtils.isAopProxy(taskScheduler)) { + //if it's a proxy then get the target class and cast as necessary + Class targetClass = AopProxyUtils.ultimateTargetClass(taskScheduler); + if (TaskScheduler.class.isAssignableFrom(targetClass)) { + taskScheduler = (TaskScheduler) AopProxyUtils.getSingletonTarget(taskScheduler); + } + } configureExistingTaskScheduler(taskScheduler, bugsnagErrorHandler); } else { - ScheduledExecutorService executorService - = beanLocator.resolveScheduledExecutorService(); + ScheduledExecutorService executorService = beanLocator.resolveScheduledExecutorService(); taskScheduler = createNewTaskScheduler(executorService, bugsnagErrorHandler); taskRegistrar.setScheduler(taskScheduler); } diff --git a/bugsnag-spring/src/jakartaTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java b/bugsnag-spring/src/jakartaTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java index 3a82d336..fde4a45c 100644 --- a/bugsnag-spring/src/jakartaTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java +++ b/bugsnag-spring/src/jakartaTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java @@ -3,16 +3,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.when; import com.bugsnag.testapp.springboot.TestSpringBootApplication; +import org.aopalliance.intercept.MethodInterceptor; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; - +import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.NoUniqueBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -113,6 +115,31 @@ public void findExecutorByName() throws NoSuchFieldException, IllegalAccessExcep assertEquals(expected, accessField(scheduler, "scheduledExecutor")); } + @Test + public void configureTasks_withProxyWrappedRegistrar() throws NoSuchFieldException, IllegalAccessException { + ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); + when(context.getBean(TaskScheduler.class)).thenReturn(scheduler); + TaskScheduler proxyScheduler = createProxy(scheduler); + registrar.setScheduler(proxyScheduler); + Object errorHandler = accessField(scheduler, "errorHandler"); + assertFalse( + errorHandler instanceof BugsnagScheduledTaskExceptionHandler, + "errorHandler should not be BugsnagScheduledTaskExceptionHandler" + ); + configuration.configureTasks(registrar); + errorHandler = accessField(scheduler, "errorHandler"); + assertTrue( + "errorHandler should be BugsnagScheduledTaskExceptionHandler", + errorHandler instanceof BugsnagScheduledTaskExceptionHandler + ); + } + + private TaskScheduler createProxy(TaskScheduler target) { + ProxyFactory factory = new ProxyFactory(target); + factory.addAdvice((MethodInterceptor) invocation -> invocation.proceed()); + return (TaskScheduler) factory.getProxy(); + } + private Object accessField(Object object, String fieldName) throws NoSuchFieldException, IllegalAccessException { Field field = object.getClass().getDeclaredField(fieldName); diff --git a/bugsnag-spring/src/javaxTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java b/bugsnag-spring/src/javaxTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java index 5de97b42..f619795d 100644 --- a/bugsnag-spring/src/javaxTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java +++ b/bugsnag-spring/src/javaxTest/java/com/bugsnag/ScheduledTaskConfigurationTest.java @@ -3,14 +3,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.when; import com.bugsnag.testapp.springboot.TestSpringBootApplication; +import org.aopalliance.intercept.MethodInterceptor; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.NoUniqueBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -111,6 +114,31 @@ public void findExecutorByName() throws NoSuchFieldException, IllegalAccessExcep assertEquals(expected, accessField(scheduler, "scheduledExecutor")); } + @Test + public void configureTasks_withProxyWrappedRegistrar() throws NoSuchFieldException, IllegalAccessException { + ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); + when(context.getBean(TaskScheduler.class)).thenReturn(scheduler); + TaskScheduler proxyScheduler = createProxy(scheduler); + registrar.setScheduler(proxyScheduler); + Object errorHandler = accessField(scheduler, "errorHandler"); + assertFalse( + errorHandler instanceof BugsnagScheduledTaskExceptionHandler, + "errorHandler should not be BugsnagScheduledTaskExceptionHandler" + ); + configuration.configureTasks(registrar); + errorHandler = accessField(scheduler, "errorHandler"); + assertTrue( + "errorHandler should be BugsnagScheduledTaskExceptionHandler", + errorHandler instanceof BugsnagScheduledTaskExceptionHandler + ); + } + + private TaskScheduler createProxy(TaskScheduler target) { + ProxyFactory factory = new ProxyFactory(target); + factory.addAdvice((MethodInterceptor) invocation -> invocation.proceed()); + return (TaskScheduler) factory.getProxy(); + } + private Object accessField(Object object, String fieldName) throws NoSuchFieldException, IllegalAccessException { Field field = object.getClass().getDeclaredField(fieldName); diff --git a/bugsnag/src/main/java/com/bugsnag/Bugsnag.java b/bugsnag/src/main/java/com/bugsnag/Bugsnag.java index 13846b41..9a036cc0 100644 --- a/bugsnag/src/main/java/com/bugsnag/Bugsnag.java +++ b/bugsnag/src/main/java/com/bugsnag/Bugsnag.java @@ -388,6 +388,9 @@ public boolean notify(Throwable throwable, Severity severity, Callback callback) LOGGER.warn("Tried to notify with a null Throwable"); return false; } + if (severity == null) { + return notify(throwable, callback); + } HandledState handledState = HandledState.newInstance( HandledState.SeverityReasonType.REASON_USER_SPECIFIED, severity); diff --git a/bugsnag/src/main/java/com/bugsnag/Configuration.java b/bugsnag/src/main/java/com/bugsnag/Configuration.java index 2ebfbe52..2682ff28 100644 --- a/bugsnag/src/main/java/com/bugsnag/Configuration.java +++ b/bugsnag/src/main/java/com/bugsnag/Configuration.java @@ -9,6 +9,7 @@ import com.bugsnag.delivery.Delivery; import com.bugsnag.delivery.HttpDelivery; import com.bugsnag.delivery.SyncHttpDelivery; +import com.bugsnag.serialization.DefaultSerializer; import com.bugsnag.serialization.Serializer; import org.slf4j.Logger; @@ -44,15 +45,14 @@ public class Configuration { public String[] projectPackages; public String releaseStage; public boolean sendThreads = false; + public Serializer serializer = new DefaultSerializer(); Collection callbacks = new ConcurrentLinkedQueue(); - Serializer serializer = new Serializer(); private final AtomicBoolean autoCaptureSessions = new AtomicBoolean(true); private final AtomicBoolean sendUncaughtExceptions = new AtomicBoolean(true); Configuration(String apiKey) { this.apiKey = apiKey; - // Add built-in callbacks addCallback(new AppCallback(this)); addCallback(new DeviceCallback()); diff --git a/bugsnag/src/main/java/com/bugsnag/Notifier.java b/bugsnag/src/main/java/com/bugsnag/Notifier.java index 3c2d2b49..fbdeb706 100644 --- a/bugsnag/src/main/java/com/bugsnag/Notifier.java +++ b/bugsnag/src/main/java/com/bugsnag/Notifier.java @@ -5,7 +5,7 @@ class Notifier { private static final String NOTIFIER_NAME = "Bugsnag Java"; - private static final String NOTIFIER_VERSION = "3.7.1"; + private static final String NOTIFIER_VERSION = "3.7.2"; private static final String NOTIFIER_URL = "https://github.com/bugsnag/bugsnag-java"; private String notifierName = NOTIFIER_NAME; diff --git a/bugsnag/src/main/java/com/bugsnag/serialization/DefaultSerializer.java b/bugsnag/src/main/java/com/bugsnag/serialization/DefaultSerializer.java new file mode 100644 index 00000000..9f5eaae3 --- /dev/null +++ b/bugsnag/src/main/java/com/bugsnag/serialization/DefaultSerializer.java @@ -0,0 +1,33 @@ +package com.bugsnag.serialization; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.io.OutputStream; + +public class DefaultSerializer implements Serializer { + private ObjectMapper mapper = new ObjectMapper(); + + /** + * Constructor. + */ + // Use deprecated method to ensure we don't break with older versions of jackson + @SuppressWarnings("deprecation") + public DefaultSerializer() { + mapper + .setSerializationInclusion(JsonInclude.Include.NON_EMPTY) + .setVisibilityChecker( + mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); + } + + @Override + public void writeToStream(OutputStream stream, Object object) throws SerializationException { + try { + mapper.writeValue(stream, object); + } catch (IOException ex) { + throw new SerializationException("Exception during serialization", ex); + } + } +} diff --git a/bugsnag/src/main/java/com/bugsnag/serialization/Serializer.java b/bugsnag/src/main/java/com/bugsnag/serialization/Serializer.java index a4a8c9bd..977133c9 100644 --- a/bugsnag/src/main/java/com/bugsnag/serialization/Serializer.java +++ b/bugsnag/src/main/java/com/bugsnag/serialization/Serializer.java @@ -1,39 +1,17 @@ package com.bugsnag.serialization; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; import java.io.OutputStream; -public class Serializer { - private ObjectMapper mapper = new ObjectMapper(); - - /** - * Constructor. - */ - // Use deprecated method to ensure we don't break with older versions of jackson - @SuppressWarnings("deprecation") - public Serializer() { - mapper - .setSerializationInclusion(JsonInclude.Include.NON_EMPTY) - .setVisibilityChecker( - mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); - } - +/** + * The Serializer is called to generate the JSON for an object to be added as metadata to a Bugsnag event. + */ +public interface Serializer { /** - * Write the object to the stream. + * Write the specified object to the provided stream to be used on metadata for a Bugsnag event. * * @param stream the stream to write the object to. * @param object the object to write to the stream. * @throws SerializationException the object could not be serialized. */ - public void writeToStream(OutputStream stream, Object object) throws SerializationException { - try { - mapper.writeValue(stream, object); - } catch (IOException ex) { - throw new SerializationException("Exception during serialization", ex); - } - } + void writeToStream(OutputStream stream, Object object) throws SerializationException; } diff --git a/bugsnag/src/test/java/com/bugsnag/ConfigurationTest.java b/bugsnag/src/test/java/com/bugsnag/ConfigurationTest.java index 4e81727a..d1afde46 100644 --- a/bugsnag/src/test/java/com/bugsnag/ConfigurationTest.java +++ b/bugsnag/src/test/java/com/bugsnag/ConfigurationTest.java @@ -8,12 +8,16 @@ import com.bugsnag.delivery.Delivery; import com.bugsnag.delivery.HttpDelivery; +import com.bugsnag.serialization.DefaultSerializer; +import com.bugsnag.serialization.SerializationException; import com.bugsnag.serialization.Serializer; import org.junit.Before; import org.junit.Test; import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.io.PrintStream; import java.net.Proxy; import java.util.LinkedList; @@ -112,6 +116,29 @@ public void testAutoCaptureOverride() { assertFalse(config.shouldAutoCaptureSessions()); } + @Test + public void testCustomSerializer() throws SerializationException { + // flag to check if writeToStream was called + final boolean[] methodCalled = {false}; + + //Anonymous class extending DefaultSerializer + Serializer customSerializer = new DefaultSerializer() { + @Override + public void writeToStream(OutputStream stream, Object object) throws SerializationException { + methodCalled[0] = true; + try { + stream.write("foo".getBytes()); + } catch (IOException exc) { + throw new SerializationException("Exception during serialization", exc); + } + } + }; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + customSerializer.writeToStream(out, new Object()); + assertTrue(methodCalled[0]); + assertEquals("foo", out.toString()); + } + @Test public void testBaseDeliveryIgnoresEndpoint() { Delivery delivery = new Delivery() { diff --git a/bugsnag/src/test/java/com/bugsnag/HandledStatePayloadTest.java b/bugsnag/src/test/java/com/bugsnag/HandledStatePayloadTest.java index b08296da..1c73a7d9 100644 --- a/bugsnag/src/test/java/com/bugsnag/HandledStatePayloadTest.java +++ b/bugsnag/src/test/java/com/bugsnag/HandledStatePayloadTest.java @@ -9,7 +9,7 @@ import com.bugsnag.HandledState.SeverityReasonType; import com.bugsnag.delivery.OutputStreamDelivery; -import com.bugsnag.serialization.Serializer; +import com.bugsnag.serialization.DefaultSerializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -178,7 +178,7 @@ private Report reportFromHandledState(HandledState handledState) { private JsonNode getJsonPayloadFromReport(Report report) throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); OutputStreamDelivery delivery = new OutputStreamDelivery(byteStream); - delivery.deliver(new Serializer(), report, Collections.emptyMap()); + delivery.deliver(new DefaultSerializer(), report, Collections.emptyMap()); String data = new String(byteStream.toByteArray()); assertNotNull(data); diff --git a/features/meta_data.feature b/features/meta_data.feature index 99c0b3ae..7d268c5b 100644 --- a/features/meta_data.feature +++ b/features/meta_data.feature @@ -160,5 +160,3 @@ Scenario: Test thread meta data in spring boot scheduled task And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.thread.key1" is null And the event "metaData.thread.key2" equals "should be included in meta data" - - diff --git a/gradle.properties b/gradle.properties index 875b5163..00edaf4a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=3.7.1 +version=3.7.2 group=com.bugsnag # Default properties