Skip to content

Commit

Permalink
v4.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Nov 29, 2018
2 parents 59720bf + 76bede4 commit a8eaa15
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.9.3 (2018-11-29)

### Bug fixes

* Handle null values in MetaData.mergeMaps, preventing potential NPE
[#386](https://github.com/bugsnag/bugsnag-android/pull/386)


## 4.9.2 (2018-11-07)

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.bugsnag.android.mazerunner.scenarios

import android.content.Context
import com.bugsnag.android.Bugsnag
import com.bugsnag.android.Configuration
import java.util.HashMap

/**
* Sends a handled exception to Bugsnag, which includes a nested null value in a metadata map
*/
internal class MetaDataNestedNullScenario(
config: Configuration,
context: Context
) : Scenario(config, context) {

init {
config.setAutoCaptureSessions(false)

}

override fun run() {
super.run()

val configMap = HashMap<String, Any?>()
configMap["test"] = null
Bugsnag.addToTab("Custom", "foo", configMap)

Bugsnag.notify(RuntimeException("MetaDataScenario")) {
val map = HashMap<String, Any?>()
map["test"] = null
it.error?.addToTab("Custom", "foo", map)
}
}

}
5 changes: 5 additions & 0 deletions features/meta_data_scenario.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ 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!"

Scenario: Add nested null value to metadata tab
When I run "MetaDataNestedNullScenario"
Then I should receive a request
And the request is a valid for the error reporting API
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=4.9.2
VERSION_NAME=4.9.3
GROUP=com.bugsnag
POM_SCM_URL=https://github.com/bugsnag/bugsnag-android
POM_SCM_CONNECTION=scm:git@github.com:bugsnag/bugsnag-android.git
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.bugsnag.android;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class MetaDataMergeTest {

@Test
public void testConcurrentMapMerge() {
MetaData.merge(generateMetaData(), generateMetaData());
}

/**
* Generates a metadata object with a tab value containing a map with a null entry
*/
private MetaData generateMetaData() {
MetaData metaData = new MetaData();
Map<Object, Object> nestedMap = new HashMap<>();
metaData.addToTab("foo", "bar", nestedMap);
nestedMap.put("whoops", null);
return metaData;
}
}
9 changes: 4 additions & 5 deletions sdk/src/main/java/com/bugsnag/android/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ private static Map<String, Object> mergeMaps(@NonNull Map<String, Object>... map
Object overridesValue = map.get(key);

if (overridesValue != null) {
if (baseValue != null
&& baseValue instanceof Map
&& overridesValue instanceof Map) {
if (baseValue instanceof Map && overridesValue instanceof Map) {
// Both original and overrides are Maps, go deeper
@SuppressWarnings("unchecked")
Map<String, Object> first = (Map<String, Object>) baseValue;
Expand All @@ -159,8 +157,9 @@ private static Map<String, Object> mergeMaps(@NonNull Map<String, Object>... map
result.put(key, overridesValue);
}
} else {
// No collision, just use base value
result.put(key, baseValue);
if (baseValue != null) { // No collision, just use base value
result.put(key, baseValue);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/com/bugsnag/android/Notifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class Notifier implements JsonStream.Streamable {

private static final String NOTIFIER_NAME = "Android Bugsnag Notifier";
private static final String NOTIFIER_VERSION = "4.9.2";
private static final String NOTIFIER_VERSION = "4.9.3";
private static final String NOTIFIER_URL = "https://bugsnag.com";

@NonNull
Expand Down

0 comments on commit a8eaa15

Please sign in to comment.