Skip to content

Commit f76d408

Browse files
Merge pull request #310 from bugsnag/next
Next release
2 parents 8a24ac6 + d436af3 commit f76d408

15 files changed

Lines changed: 398 additions & 101 deletions

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## 4.3.4 (2018-05-02)
4+
5+
### Bug fixes
6+
7+
* Avoid adding extra comma separator in JSON if File input is empty or null
8+
[#284](https://github.com/bugsnag/bugsnag-android/pull/284)
9+
10+
* Thread safety fixes to JSON file serialisation
11+
[#295](https://github.com/bugsnag/bugsnag-android/pull/295)
12+
13+
* Prevent potential automatic activity lifecycle breadcrumb crash
14+
[#300](https://github.com/bugsnag/bugsnag-android/pull/300)
15+
16+
* Fix serialisation issue with leading to incorrect dashboard display of breadcrumbs
17+
[#306](https://github.com/bugsnag/bugsnag-android/pull/306)
18+
319
## 4.3.3 (2018-04-04)
420

521
### Bug fixes

features/breadcrumb.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Scenario: Manually added breadcrumbs are sent in report
1313
And the event "breadcrumbs.1.metaData.Foo" equals "Bar"
1414

1515
And the event "breadcrumbs.0.timestamp" is not null
16-
And the event "breadcrumbs.0.name" equals "Hello Breadcrumb!"
16+
And the event "breadcrumbs.0.name" equals "manual"
1717
And the event "breadcrumbs.0.type" equals "manual"
1818
And the event "breadcrumbs.0.metaData" is not null
19+
And the event "breadcrumbs.0.metaData.message" equals "Hello Breadcrumb!"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx1536m
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
14-
VERSION_NAME=4.3.3
14+
VERSION_NAME=4.3.4
1515
GROUP=com.bugsnag
1616
POM_SCM_URL=https://github.com/bugsnag/bugsnag-android
1717
POM_SCM_CONNECTION=scm:git@github.com:bugsnag/bugsnag-android.git
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.bugsnag.android;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.filters.SmallTest;
6+
import android.support.test.runner.AndroidJUnit4;
7+
8+
import org.junit.Before;
9+
import org.junit.Test;
10+
import org.junit.runner.RunWith;
11+
12+
@RunWith(AndroidJUnit4.class)
13+
@SmallTest
14+
public class BreadcrumbLifecycleCrashTest {
15+
16+
private SessionTracker sessionTracker;
17+
18+
/**
19+
* Creates a SessionTracker with a null client
20+
*
21+
* @throws Exception if the SessionTracker couldn't be created
22+
*/
23+
@Before
24+
public void setUp() throws Exception {
25+
Configuration configuration = new Configuration("api-key");
26+
Context context = InstrumentationRegistry.getContext();
27+
SessionStore sessionStore = new SessionStore(configuration, context);
28+
SessionTrackingApiClient apiClient = BugsnagTestUtils.generateSessionTrackingApiClient();
29+
sessionTracker = new SessionTracker(configuration, null, sessionStore, apiClient);
30+
}
31+
32+
@Test
33+
public void testLifecycleBreadcrumbCrash() {
34+
// should not crash with a null client
35+
sessionTracker.leaveLifecycleBreadcrumb("FooActivity", "onCreate");
36+
}
37+
38+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.bugsnag.android;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
import static org.junit.Assert.assertNull;
6+
import static org.junit.Assert.assertTrue;
7+
8+
import android.support.test.filters.SmallTest;
9+
import android.support.test.runner.AndroidJUnit4;
10+
11+
import org.junit.Before;
12+
import org.junit.Test;
13+
import org.junit.runner.RunWith;
14+
15+
import java.util.Map;
16+
import java.util.concurrent.CountDownLatch;
17+
import java.util.concurrent.TimeUnit;
18+
19+
@RunWith(AndroidJUnit4.class)
20+
@SmallTest
21+
public class ClientNotifyAsyncTest {
22+
23+
private Client client;
24+
private NullCheckClient apiClient;
25+
26+
/**
27+
* Generates a configuration and clears sharedPrefs values to begin the test with a clean slate
28+
*
29+
* @throws Exception if initialisation failed
30+
*/
31+
@Before
32+
public void setUp() throws Exception {
33+
client = BugsnagTestUtils.generateClient();
34+
apiClient = new NullCheckClient();
35+
client.setErrorReportApiClient(apiClient);
36+
}
37+
38+
@Test
39+
public void testNotifyAsyncMetadata() throws Exception {
40+
MetaData metaData = new MetaData();
41+
metaData.addToTab("animals", "dog", true);
42+
43+
client.notify(new RuntimeException("Foo"), metaData);
44+
assertNull(apiClient.report);
45+
apiClient.nullCheckLatch.countDown();
46+
47+
apiClient.awaitReport();
48+
assertNotNull(apiClient.report);
49+
MetaData data = apiClient.report.getError().getMetaData();
50+
assertTrue((Boolean) data.getTab("animals").get("dog"));
51+
}
52+
53+
@Test
54+
public void testNotifyAsyncSeverity() throws Exception {
55+
client.notify(new RuntimeException("Foo"), Severity.INFO);
56+
assertNull(apiClient.report);
57+
apiClient.nullCheckLatch.countDown();
58+
59+
apiClient.awaitReport();
60+
assertNotNull(apiClient.report);
61+
assertEquals(Severity.INFO, apiClient.report.getError().getSeverity());
62+
}
63+
64+
@Test
65+
public void testNotifyAsyncSeverityMetadata() throws Exception {
66+
MetaData metaData = new MetaData();
67+
metaData.addToTab("animals", "bird", "chicken");
68+
69+
client.notify(new RuntimeException("Foo"), Severity.ERROR, metaData);
70+
assertNull(apiClient.report);
71+
apiClient.nullCheckLatch.countDown();
72+
73+
apiClient.awaitReport();
74+
assertNotNull(apiClient.report);
75+
MetaData data = apiClient.report.getError().getMetaData();
76+
assertEquals("chicken", data.getTab("animals").get("bird"));
77+
assertEquals(Severity.ERROR, apiClient.report.getError().getSeverity());
78+
}
79+
80+
@Test
81+
public void testNotifyAsyncCallback() throws Exception {
82+
client.notify(new RuntimeException("Foo"), new Callback() {
83+
@Override
84+
public void beforeNotify(Report report) {
85+
report.getError().setContext("Manual");
86+
}
87+
});
88+
assertNull(apiClient.report);
89+
apiClient.nullCheckLatch.countDown();
90+
91+
apiClient.awaitReport();
92+
assertNotNull(apiClient.report);
93+
assertEquals("Manual", apiClient.report.getError().getContext());
94+
}
95+
96+
static class NullCheckClient extends ClientNotifyTest.FakeClient {
97+
98+
CountDownLatch nullCheckLatch = new CountDownLatch(1);
99+
100+
@Override
101+
public void postReport(String urlString,
102+
Report report,
103+
Map<String, String> headers)
104+
throws NetworkException, BadResponseException {
105+
try {
106+
nullCheckLatch.await(100, TimeUnit.MILLISECONDS);
107+
} catch (InterruptedException exception) {
108+
exception.printStackTrace();
109+
}
110+
super.postReport(urlString, report, headers);
111+
}
112+
}
113+
114+
}

sdk/src/androidTest/java/com/bugsnag/android/ClientNotifyTest.java

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.bugsnag.android;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
import static org.junit.Assert.assertNull;
6-
import static org.junit.Assert.assertTrue;
74

85
import android.support.test.filters.SmallTest;
96
import android.support.test.runner.AndroidJUnit4;
@@ -78,60 +75,6 @@ public void beforeNotify(Report report) {
7875
assertEquals("Message", error.getExceptionMessage());
7976
}
8077

81-
@Test
82-
public void testNotifyAsyncMetadata() throws Exception {
83-
MetaData metaData = new MetaData();
84-
metaData.addToTab("animals", "dog", true);
85-
86-
client.notify(new RuntimeException("Foo"), metaData);
87-
assertNull(apiClient.report);
88-
89-
apiClient.awaitReport();
90-
assertNotNull(apiClient.report);
91-
MetaData data = apiClient.report.getError().getMetaData();
92-
assertTrue((Boolean) data.getTab("animals").get("dog"));
93-
}
94-
95-
@Test
96-
public void testNotifyAsyncSeverity() throws Exception {
97-
client.notify(new RuntimeException("Foo"), Severity.INFO);
98-
assertNull(apiClient.report);
99-
100-
apiClient.awaitReport();
101-
assertNotNull(apiClient.report);
102-
assertEquals(Severity.INFO, apiClient.report.getError().getSeverity());
103-
}
104-
105-
@Test
106-
public void testNotifyAsyncSeverityMetadata() throws Exception {
107-
MetaData metaData = new MetaData();
108-
metaData.addToTab("animals", "bird", "chicken");
109-
110-
client.notify(new RuntimeException("Foo"), Severity.ERROR, metaData);
111-
assertNull(apiClient.report);
112-
113-
apiClient.awaitReport();
114-
assertNotNull(apiClient.report);
115-
MetaData data = apiClient.report.getError().getMetaData();
116-
assertEquals("chicken", data.getTab("animals").get("bird"));
117-
assertEquals(Severity.ERROR, apiClient.report.getError().getSeverity());
118-
}
119-
120-
@Test
121-
public void testNotifyAsyncCallback() throws Exception {
122-
client.notify(new RuntimeException("Foo"), new Callback() {
123-
@Override
124-
public void beforeNotify(Report report) {
125-
report.getError().setContext("Manual");
126-
}
127-
});
128-
assertNull(apiClient.report);
129-
130-
apiClient.awaitReport();
131-
assertNotNull(apiClient.report);
132-
assertEquals("Manual", apiClient.report.getError().getContext());
133-
}
134-
13578
static class FakeClient implements ErrorReportApiClient {
13679

13780
CountDownLatch latch = new CountDownLatch(1);
@@ -143,7 +86,7 @@ public void postReport(String urlString,
14386
Map<String, String> headers)
14487
throws NetworkException, BadResponseException {
14588
try {
146-
Thread.sleep(1); // simulate async request
89+
Thread.sleep(10); // simulate async request
14790
} catch (InterruptedException ignored) {
14891
ignored.printStackTrace();
14992
}

0 commit comments

Comments
 (0)