From 5d8fb883cbda3e33b2e2eaac1ad800a740ec8fd2 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 12:52:21 +0100 Subject: [PATCH 01/10] test: add mazerunner scenarios for verifying runtimeVersions are in payload --- features/runtime_versions.feature | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 features/runtime_versions.feature diff --git a/features/runtime_versions.feature b/features/runtime_versions.feature new file mode 100644 index 00000000..7d91174e --- /dev/null +++ b/features/runtime_versions.feature @@ -0,0 +1,53 @@ +Feature: Runtime versions are included in all requests + +### Errors + +Scenario: Runtime versions included in Plain Java error + When I run "HandledExceptionScenario" with the defaults + Then I should receive a request + And the request is valid for the error reporting API + And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" + And the payload field "events.0.device.runtimeVersions.javaVersion" starts with "1." + +Scenario: Runtime versions included in Spring Framework error + When I run plain Spring "HandledExceptionScenario" with the defaults + Then I should receive a request + And the request is valid for the error reporting API + And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" + And the payload field "events.0.device.runtimeVersions.javaVersion" starts with "1." + And the payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" + +Scenario: Runtime versions included in Spring Boot error + When I run spring boot "HandledExceptionScenario" with the defaults + Then I should receive a request + And the request is valid for the error reporting API + And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" + And the payload field "events.0.device.runtimeVersions.javaVersion" starts with "1." + And the payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" + And the payload field "events.0.device.runtimeVersions.springBoot" matches the regex "(\d.)+" + +### Sessions + +Scenario: Runtime versions included in Plain Java session + When I run "ManualSessionScenario" with the defaults + Then I should receive a request + And the request is valid for the session tracking API + And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" + And the payload field "device.runtimeVersions.javaVersion" starts with "1." + +Scenario: Runtime versions included in Spring Framework session + When I run plain Spring "ManualSessionScenario" with the defaults + Then I should receive a request + And the request is valid for the session tracking API + And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" + And the payload field "device.runtimeVersions.javaVersion" starts with "1." + And the payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" + +Scenario: Runtime versions included in Spring Boot session + When I run spring boot "ManualSessionScenario" with the defaults + Then I should receive a request + And the request is valid for the session tracking API + And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" + And the payload field "device.runtimeVersions.javaVersion" starts with "1." + And the payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" + And the payload field "device.runtimeVersions.springBoot" matches the regex "(\d.)+" From 2c87d10d491f5b6c473846a65c0b090f2c4a1e9f Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 12:56:49 +0100 Subject: [PATCH 02/10] feat: add BeforeSendSession callback to internal API BeforeSendSession is invoked immediately before a SessionPayload is queued for delivery. This allows for the mutation of the payload if required by different frameworks (e.g. Spring). This is currently an internal API and not accessible to users. --- .../src/main/java/com/bugsnag/BeforeSendSession.java | 5 +++++ bugsnag/src/main/java/com/bugsnag/Bugsnag.java | 4 ++++ bugsnag/src/main/java/com/bugsnag/SessionTracker.java | 10 ++++++++++ 3 files changed, 19 insertions(+) create mode 100644 bugsnag/src/main/java/com/bugsnag/BeforeSendSession.java diff --git a/bugsnag/src/main/java/com/bugsnag/BeforeSendSession.java b/bugsnag/src/main/java/com/bugsnag/BeforeSendSession.java new file mode 100644 index 00000000..dcd6a50d --- /dev/null +++ b/bugsnag/src/main/java/com/bugsnag/BeforeSendSession.java @@ -0,0 +1,5 @@ +package com.bugsnag; + +interface BeforeSendSession { + void beforeSendSession(SessionPayload payload); +} diff --git a/bugsnag/src/main/java/com/bugsnag/Bugsnag.java b/bugsnag/src/main/java/com/bugsnag/Bugsnag.java index b9e64414..81f9553f 100644 --- a/bugsnag/src/main/java/com/bugsnag/Bugsnag.java +++ b/bugsnag/src/main/java/com/bugsnag/Bugsnag.java @@ -665,4 +665,8 @@ public static Set uncaughtExceptionClients() { } return Collections.emptySet(); } + + void addBeforeSendSession(BeforeSendSession beforeSendSession) { + sessionTracker.addBeforeSendSession(beforeSendSession); + } } diff --git a/bugsnag/src/main/java/com/bugsnag/SessionTracker.java b/bugsnag/src/main/java/com/bugsnag/SessionTracker.java index b0351c42..d0a50472 100644 --- a/bugsnag/src/main/java/com/bugsnag/SessionTracker.java +++ b/bugsnag/src/main/java/com/bugsnag/SessionTracker.java @@ -21,6 +21,7 @@ class SessionTracker { private final Semaphore flushingRequest = new Semaphore(1); private final AtomicBoolean shuttingDown = new AtomicBoolean(); + private final Collection sessionCallbacks = new ConcurrentLinkedQueue(); SessionTracker(Configuration configuration) { this.config = configuration; @@ -88,6 +89,11 @@ private void sendSessions(Date now) { Collection requestValues = new ArrayList(enqueuedSessionCounts); SessionPayload payload = new SessionPayload(requestValues, config); + + for (BeforeSendSession callback : sessionCallbacks) { + callback.beforeSendSession(payload); + } + Delivery delivery = config.sessionDelivery; delivery.deliver(config.serializer, payload, config.getSessionApiHeaders()); enqueuedSessionCounts.removeAll(requestValues); @@ -102,4 +108,8 @@ void shutdown() { sendSessions(new Date(Long.MAX_VALUE)); // flush all remaining sessions } } + + void addBeforeSendSession(BeforeSendSession beforeSendSession) { + sessionCallbacks.add(beforeSendSession); + } } From bb08ae72139ceea7b6cdb95027d66b4ebd03d955 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 13:00:54 +0100 Subject: [PATCH 03/10] feat: report java type + version in device.runtimeVersions by default --- bugsnag/src/main/java/com/bugsnag/Diagnostics.java | 8 ++++++++ .../main/java/com/bugsnag/callbacks/DeviceCallback.java | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bugsnag/src/main/java/com/bugsnag/Diagnostics.java b/bugsnag/src/main/java/com/bugsnag/Diagnostics.java index 30082ce4..2a9918d1 100644 --- a/bugsnag/src/main/java/com/bugsnag/Diagnostics.java +++ b/bugsnag/src/main/java/com/bugsnag/Diagnostics.java @@ -23,9 +23,17 @@ private Map getDefaultDeviceInfo() { map.put("hostname", DeviceCallback.getHostnameValue()); map.put("osName", System.getProperty("os.name")); map.put("osVersion", System.getProperty("os.version")); + map.put("runtimeVersions", getRuntimeVersions()); return map; } + private Map getRuntimeVersions() { + Map runtimeVersions = new HashMap(); + runtimeVersions.put("javaType", System.getProperty("java.runtime.name")); + runtimeVersions.put("javaVersion", System.getProperty("java.runtime.version")); + return runtimeVersions; + } + private Map getDefaultAppInfo(Configuration configuration) { Map map = new HashMap(); diff --git a/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java b/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java index b299569e..8ee7e57c 100644 --- a/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java +++ b/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java @@ -56,8 +56,6 @@ public static void initializeCache() { public void beforeNotify(Report report) { report .addToTab("device", "osArch", System.getProperty("os.arch")) - .addToTab("device", "runtimeName", System.getProperty("java.runtime.name")) - .addToTab("device", "runtimeVersion", System.getProperty("java.runtime.version")) .addToTab("device", "locale", Locale.getDefault()) .setDeviceInfo("hostname", getHostnameValue()) .setDeviceInfo("osName", System.getProperty("os.name")) From 67a5abf06f90dd738e363f2df484191a55bde191 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 13:12:33 +0100 Subject: [PATCH 04/10] feat: record spring framework version for errors and sessions --- .../bugsnag/BugsnagSpringConfiguration.java | 21 +++++++++++++++++-- .../main/java/com/bugsnag/Diagnostics.java | 13 ++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java b/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java index 0e3440c5..9c61fe04 100644 --- a/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java +++ b/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java @@ -9,6 +9,7 @@ import org.springframework.core.SpringVersion; import javax.annotation.PostConstruct; +import java.util.Map; /** * Configuration to integrate Bugsnag with Spring. @@ -27,17 +28,33 @@ public class BugsnagSpringConfiguration { * Add a callback to add the version of Spring used by the application */ @Bean - Callback springVersionCallback() { + Callback springVersionErrorCallback() { Callback callback = new Callback() { @Override public void beforeNotify(Report report) { - report.addToTab("device", "springVersion", SpringVersion.getVersion()); + appendSpringRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(report.getDevice())); } }; bugsnag.addCallback(callback); return callback; } + @Bean + BeforeSendSession springVersionSessionCallback() { + BeforeSendSession beforeSendSession = new BeforeSendSession() { + @Override + public void beforeSendSession(SessionPayload payload) { + appendSpringRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(payload.getDevice())); + } + }; + bugsnag.addBeforeSendSession(beforeSendSession); + return beforeSendSession; + } + + private void appendSpringRuntimeVersion(Map runtimeVersions) { + runtimeVersions.put("springFramework", SpringVersion.getVersion()); + } + @Bean ScheduledTaskBeanLocator scheduledTaskBeanLocator() { return new ScheduledTaskBeanLocator(); diff --git a/bugsnag/src/main/java/com/bugsnag/Diagnostics.java b/bugsnag/src/main/java/com/bugsnag/Diagnostics.java index 2a9918d1..ab4f3448 100644 --- a/bugsnag/src/main/java/com/bugsnag/Diagnostics.java +++ b/bugsnag/src/main/java/com/bugsnag/Diagnostics.java @@ -45,4 +45,17 @@ private Map getDefaultAppInfo(Configuration configuration) { } return map; } + + @SuppressWarnings("unchecked") + static Map retrieveRuntimeVersionsMap(Map device) { + Object obj = device.get("runtimeVersions"); + + if (obj instanceof Map) { + return (Map) obj; + } else { // fallback to creating a new map if payload was mutated + Map map = new HashMap(); + device.put("runtimeVersions", map); + return map; + } + } } From bb18702a80b9b76d3202da36e793110255efa391 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 13:13:06 +0100 Subject: [PATCH 05/10] feat: record spring boot framework version for errors and sessions --- .../com/bugsnag/SpringBootConfiguration.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java b/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java index f788f206..594c4cc6 100644 --- a/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java +++ b/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java @@ -11,6 +11,7 @@ import org.springframework.context.annotation.Configuration; import javax.servlet.ServletRequestListener; +import java.util.Map; /** * If spring-boot is loaded, add configuration specific to Spring Boot @@ -26,17 +27,33 @@ class SpringBootConfiguration { * Add a callback to add the version of Spring Boot used by the application. */ @Bean - Callback springBootVersionCallback() { + Callback springBootVersionErrorCallback() { Callback callback = new Callback() { @Override public void beforeNotify(Report report) { - report.addToTab("device", "springBootVersion", SpringBootVersion.getVersion()); + appendSpringBootRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(report.getDevice())); } }; bugsnag.addCallback(callback); return callback; } + @Bean + BeforeSendSession springBootVersionSessionCallback() { + BeforeSendSession beforeSendSession = new BeforeSendSession() { + @Override + public void beforeSendSession(SessionPayload payload) { + appendSpringBootRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(payload.getDevice())); + } + }; + bugsnag.addBeforeSendSession(beforeSendSession); + return beforeSendSession; + } + + private void appendSpringBootRuntimeVersion(Map runtimeVersions) { + runtimeVersions.put("springBoot", SpringBootVersion.getVersion()); + } + /** * The {@link com.bugsnag.servlet.BugsnagServletContainerInitializer} does not work for Spring Boot, need to * register the {@link BugsnagServletRequestListener} using a Spring Boot From 728c817cac42ea58aa19ce40b2930439b7d9de74 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 13:35:48 +0100 Subject: [PATCH 06/10] test: pass existing tests --- .../java/com/bugsnag/BugsnagSpringConfiguration.java | 2 +- .../main/java/com/bugsnag/SpringBootConfiguration.java | 2 +- .../src/test/java/com/bugsnag/SpringMvcTest.java | 10 ++++++---- .../src/test/java/com/bugsnag/SessionPayloadTest.java | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java b/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java index 9c61fe04..9d4437c7 100644 --- a/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java +++ b/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java @@ -8,8 +8,8 @@ import org.springframework.context.annotation.Import; import org.springframework.core.SpringVersion; -import javax.annotation.PostConstruct; import java.util.Map; +import javax.annotation.PostConstruct; /** * Configuration to integrate Bugsnag with Spring. diff --git a/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java b/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java index 594c4cc6..8d799a12 100644 --- a/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java +++ b/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java @@ -10,8 +10,8 @@ import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; -import javax.servlet.ServletRequestListener; import java.util.Map; +import javax.servlet.ServletRequestListener; /** * If spring-boot is loaded, add configuration specific to Spring Boot diff --git a/bugsnag-spring/src/test/java/com/bugsnag/SpringMvcTest.java b/bugsnag-spring/src/test/java/com/bugsnag/SpringMvcTest.java index eb2f0473..694bb98b 100644 --- a/bugsnag-spring/src/test/java/com/bugsnag/SpringMvcTest.java +++ b/bugsnag-spring/src/test/java/com/bugsnag/SpringMvcTest.java @@ -157,16 +157,18 @@ public void requestMetadataSetCorrectly() { } @Test + @SuppressWarnings("unchecked") public void springVersionSetCorrectly() { callRuntimeExceptionEndpoint(); Report report = verifyAndGetReport(delivery); // Check that the Spring version is set as expected - @SuppressWarnings(value = "unchecked") Map deviceMetadata = - (Map) report.getMetaData().get("device"); - assertEquals(SpringVersion.getVersion(), deviceMetadata.get("springVersion")); - assertEquals(SpringBootVersion.getVersion(), deviceMetadata.get("springBootVersion")); + Map deviceMetadata = report.getDevice(); + Map runtimeVersions = + (Map) deviceMetadata.get("runtimeVersions"); + assertEquals(SpringVersion.getVersion(), runtimeVersions.get("springFramework")); + assertEquals(SpringBootVersion.getVersion(), runtimeVersions.get("springBoot")); } @Test diff --git a/bugsnag/src/test/java/com/bugsnag/SessionPayloadTest.java b/bugsnag/src/test/java/com/bugsnag/SessionPayloadTest.java index d18ae502..c60c16c1 100644 --- a/bugsnag/src/test/java/com/bugsnag/SessionPayloadTest.java +++ b/bugsnag/src/test/java/com/bugsnag/SessionPayloadTest.java @@ -63,7 +63,7 @@ public void testJsonSerialisation() { JsonNode device = rootNode.get("device"); assertNotNull(device); - assertEquals(3, device.size()); + assertEquals(4, device.size()); } } From c79eabc699d0c03371510445f33255ba3f3bd42b Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 14:26:20 +0100 Subject: [PATCH 07/10] test: correct existing mazerunner scenarios as per review feedback --- features/meta_data.feature | 4 ---- features/runtime_versions.feature | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/features/meta_data.feature b/features/meta_data.feature index 9f911388..0a81e7fa 100644 --- a/features/meta_data.feature +++ b/features/meta_data.feature @@ -10,8 +10,6 @@ Scenario: Sends a handled exception which includes custom metadata added in a no When I run spring boot "MetaDataScenario" with the defaults Then I should receive a request And the request is a valid for the error reporting API - And the event "metaData.device.springVersion" is not null - And the event "metaData.device.springBootVersion" is not null And the event "metaData.Custom.foo" equals "Hello World!" Scenario: Sends a handled exception which includes custom metadata added in a notify callback for plain Spring app @@ -19,8 +17,6 @@ Scenario: Sends a handled exception which includes custom metadata added in a no Then I should receive a request And the request is a valid for the error reporting API And the event "metaData.Custom.foo" equals "Hello World!" - And the event "metaData.device.springVersion" is not null - And the event "metaData.device.springBootVersion" is null Scenario: Test logback appender with meta data in the config file When I run "LogbackScenario" with logback config "meta_data_config.xml" diff --git a/features/runtime_versions.feature b/features/runtime_versions.feature index 7d91174e..c40afda2 100644 --- a/features/runtime_versions.feature +++ b/features/runtime_versions.feature @@ -7,14 +7,14 @@ Scenario: Runtime versions included in Plain Java error Then I should receive a request And the request is valid for the error reporting API And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "events.0.device.runtimeVersions.javaVersion" starts with "1." + And the payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Framework error When I run plain Spring "HandledExceptionScenario" with the defaults Then I should receive a request And the request is valid for the error reporting API And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "events.0.device.runtimeVersions.javaVersion" starts with "1." + And the payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" And the payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Boot error @@ -22,7 +22,7 @@ Scenario: Runtime versions included in Spring Boot error Then I should receive a request And the request is valid for the error reporting API And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "events.0.device.runtimeVersions.javaVersion" starts with "1." + And the payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" And the payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" And the payload field "events.0.device.runtimeVersions.springBoot" matches the regex "(\d.)+" @@ -33,14 +33,14 @@ Scenario: Runtime versions included in Plain Java session Then I should receive a request And the request is valid for the session tracking API And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "device.runtimeVersions.javaVersion" starts with "1." + And the payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Framework session When I run plain Spring "ManualSessionScenario" with the defaults Then I should receive a request And the request is valid for the session tracking API And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "device.runtimeVersions.javaVersion" starts with "1." + And the payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" And the payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Boot session @@ -48,6 +48,6 @@ Scenario: Runtime versions included in Spring Boot session Then I should receive a request And the request is valid for the session tracking API And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "device.runtimeVersions.javaVersion" starts with "1." + And the payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" And the payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" And the payload field "device.runtimeVersions.springBoot" matches the regex "(\d.)+" From 1a248e510f9fba28480b6e5ff850fff36311b2b0 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 17 Apr 2019 16:53:23 +0100 Subject: [PATCH 08/10] docs: add changelog entry --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29bb6d43..44d6d2b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.X.X (TBD) + +* Migrate version information to device.runtimeVersions + [#141](https://github.com/bugsnag/bugsnag-java/pull/141) + ## 3.4.6 (2019-04-16) * Swallow Throwables thrown when configuring bugsnag appender From b21823f40b853701aac1133d98bd86e3a29dbb94 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Wed, 24 Apr 2019 14:41:56 +0100 Subject: [PATCH 09/10] refactor: reorganise how runtimeVersions are appended --- .../java/com/bugsnag/BugsnagSpringConfiguration.java | 8 ++++---- .../java/com/bugsnag/SpringBootConfiguration.java | 8 ++++---- bugsnag/src/main/java/com/bugsnag/Diagnostics.java | 11 ++++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java b/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java index 9d4437c7..36fd5ea6 100644 --- a/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java +++ b/bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java @@ -32,7 +32,7 @@ Callback springVersionErrorCallback() { Callback callback = new Callback() { @Override public void beforeNotify(Report report) { - appendSpringRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(report.getDevice())); + addSpringRuntimeVersion(report.getDevice()); } }; bugsnag.addCallback(callback); @@ -44,15 +44,15 @@ BeforeSendSession springVersionSessionCallback() { BeforeSendSession beforeSendSession = new BeforeSendSession() { @Override public void beforeSendSession(SessionPayload payload) { - appendSpringRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(payload.getDevice())); + addSpringRuntimeVersion(payload.getDevice()); } }; bugsnag.addBeforeSendSession(beforeSendSession); return beforeSendSession; } - private void appendSpringRuntimeVersion(Map runtimeVersions) { - runtimeVersions.put("springFramework", SpringVersion.getVersion()); + private void addSpringRuntimeVersion(Map device) { + Diagnostics.addDeviceRuntimeVersion(device, "springFramework", SpringVersion.getVersion()); } @Bean diff --git a/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java b/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java index 8d799a12..e1a68105 100644 --- a/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java +++ b/bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java @@ -31,7 +31,7 @@ Callback springBootVersionErrorCallback() { Callback callback = new Callback() { @Override public void beforeNotify(Report report) { - appendSpringBootRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(report.getDevice())); + addSpringRuntimeVersion(report.getDevice()); } }; bugsnag.addCallback(callback); @@ -43,15 +43,15 @@ BeforeSendSession springBootVersionSessionCallback() { BeforeSendSession beforeSendSession = new BeforeSendSession() { @Override public void beforeSendSession(SessionPayload payload) { - appendSpringBootRuntimeVersion(Diagnostics.retrieveRuntimeVersionsMap(payload.getDevice())); + addSpringRuntimeVersion(payload.getDevice()); } }; bugsnag.addBeforeSendSession(beforeSendSession); return beforeSendSession; } - private void appendSpringBootRuntimeVersion(Map runtimeVersions) { - runtimeVersions.put("springBoot", SpringBootVersion.getVersion()); + private void addSpringRuntimeVersion(Map device) { + Diagnostics.addDeviceRuntimeVersion(device, "springBoot", SpringBootVersion.getVersion()); } /** diff --git a/bugsnag/src/main/java/com/bugsnag/Diagnostics.java b/bugsnag/src/main/java/com/bugsnag/Diagnostics.java index ab4f3448..d6aa3e1a 100644 --- a/bugsnag/src/main/java/com/bugsnag/Diagnostics.java +++ b/bugsnag/src/main/java/com/bugsnag/Diagnostics.java @@ -47,15 +47,16 @@ private Map getDefaultAppInfo(Configuration configuration) { } @SuppressWarnings("unchecked") - static Map retrieveRuntimeVersionsMap(Map device) { + static void addDeviceRuntimeVersion(Map device, String key, Object value) { Object obj = device.get("runtimeVersions"); + Map runtimeVersions; if (obj instanceof Map) { - return (Map) obj; + runtimeVersions = (Map) obj; } else { // fallback to creating a new map if payload was mutated - Map map = new HashMap(); - device.put("runtimeVersions", map); - return map; + runtimeVersions = new HashMap(); + device.put("runtimeVersions", runtimeVersions); } + runtimeVersions.put(key, value); } } From 83481304b371229d24c4aa2b9703e245c2e8f398 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Tue, 7 May 2019 10:49:08 +0100 Subject: [PATCH 10/10] prepare for v3.5.0 --- CHANGELOG.md | 2 +- bugsnag/src/main/java/com/bugsnag/Notifier.java | 2 +- gradle.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d6d2b9..045c2515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 3.X.X (TBD) +## 3.5.0 (2019-05-07) * Migrate version information to device.runtimeVersions [#141](https://github.com/bugsnag/bugsnag-java/pull/141) diff --git a/bugsnag/src/main/java/com/bugsnag/Notifier.java b/bugsnag/src/main/java/com/bugsnag/Notifier.java index 415d3874..d25ea8a7 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.4.6"; + private static final String NOTIFIER_VERSION = "3.5.0"; private static final String NOTIFIER_URL = "https://github.com/bugsnag/bugsnag-java"; private String notifierName = NOTIFIER_NAME; diff --git a/gradle.properties b/gradle.properties index 36a74498..20ebf634 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=3.4.6 +version=3.5.0 group=com.bugsnag # Default properties