Skip to content

Commit

Permalink
Merge pull request #98 from bugsnag/next
Browse files Browse the repository at this point in the history
v3.2.1
  • Loading branch information
fractalwrench authored Aug 21, 2018
2 parents b17d7f3 + 646f862 commit 188ea20
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 3.2.1 (2018-08-21)

* Add null check when disconnecting HttpUrlConnection
[#92](https://github.com/bugsnag/bugsnag-java/pull/92)

* Make constructors public for SyncHttpDelivery
[#97](https://github.com/bugsnag/bugsnag-java/pull/97)

## 3.2.0 (2018-07-03)

This release introduces automatic tracking of sessions, which by
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ test {
checkstyle {
toolVersion = "6.16"
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
// fail build on warnings, disable options complaining about Java 6 compatibility when building with JDK 7+
options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-options"
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.2.0
version=3.2.1
group=com.bugsnag

# Default properties
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/bugsnag/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Map;

class MetaData extends HashMap<String, Object> {
private static final long serialVersionUID = 2530038179702722770L;

public void addToTab(String tabName, String key, Object value) {
Map<String, Object> tab = getTab(tabName);
tab.put(key, value);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bugsnag/Notifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Notifier {
private static final String NOTIFIER_NAME = "Bugsnag Java";
private static final String NOTIFIER_VERSION = "3.2.0";
private static final String NOTIFIER_VERSION = "3.2.1";
private static final String NOTIFIER_URL = "https://github.com/bugsnag/bugsnag-java";

@Expose
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/bugsnag/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ public String getContext() {
}

@Expose
public Map getApp() {
public Map<String, Object> getApp() {
return diagnostics.app;
}

@Expose
public Map getDevice() {
public Map<String, Object> getDevice() {
return diagnostics.device;
}

@Expose
public Map getUser() {
public Map<String, String> getUser() {
return diagnostics.user;
}

@Expose
public Map getMetaData() {
public Map<String, Object> getMetaData() {
return new FilteredMap(diagnostics.metaData, Arrays.asList(config.filters));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/bugsnag/callbacks/ServletCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ private String getClientIp(HttpServletRequest request) {

private Map<String, String> getHeaderMap(HttpServletRequest request) {
Map<String, String> map = new HashMap<String, String>();
Enumeration headerNames = request.getHeaderNames();
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String key = headerNames.nextElement();
map.put(key, request.getHeader(key));
}

Expand Down
18 changes: 15 additions & 3 deletions src/main/java/com/bugsnag/delivery/SyncHttpDelivery.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@ public class SyncHttpDelivery implements HttpDelivery {
public static final String DEFAULT_SESSION_ENDPOINT = "https://sessions.bugsnag.com";
protected static final int DEFAULT_TIMEOUT = 5000;

protected String endpoint = DEFAULT_NOTIFY_ENDPOINT;
protected String endpoint;
protected int timeout = DEFAULT_TIMEOUT;
protected Proxy proxy;

SyncHttpDelivery(String endpoint) {
/**
* Creates a new instance, which defaults to the https://notify.bugsnag.com endpoint
*/
public SyncHttpDelivery() {
this(SyncHttpDelivery.DEFAULT_NOTIFY_ENDPOINT);
}

/**
* Creates a new instance, which uses a custom endpoint
*/
public SyncHttpDelivery(String endpoint) {
this.endpoint = endpoint;
}

Expand Down Expand Up @@ -97,7 +107,9 @@ public void deliver(Serializer serializer, Object object, Map<String, String> he
} catch (IOException ex) {
logger.warn("Error not reported to Bugsnag - exception when making request", ex);
} finally {
connection.disconnect();
if (connection != null) {
connection.disconnect();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.bugsnag.serialization;

public class SerializationException extends Exception {
private static final long serialVersionUID = -6782171186575335048L;

public SerializationException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bugsnag/util/FilteredMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public Set<Entry<String, Object>> entrySet() {
return filteredCopy.entrySet();
}

@SuppressWarnings("unchecked")
private Object transformEntry(Object key, Object value) {
if (value instanceof Map) {
//noinspection unchecked
return new FilteredMap((Map<String, Object>) value, keyFilters);
}
return shouldFilterKey((String) key) ? FILTERED_PLACEHOLDER : value;
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/com/bugsnag/BugsnagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,14 @@ public void testFilters() {
Bugsnag bugsnag = new Bugsnag("apikey");
bugsnag.setFilters("testfilter1", "testfilter2");
bugsnag.setDelivery(new Delivery() {
@SuppressWarnings("unchecked")
@Override
public void deliver(Serializer serializer, Object object, Map<String, String> headers) {
Report report = ((Notification) object).getEvents().get(0);
Map firstTab = (Map) report.getMetaData().get("firsttab");
final Map secondTab = (Map) report.getMetaData().get("secondtab");
Map<String, Object> firstTab =
(Map<String, Object>) report.getMetaData().get("firsttab");
final Map<String, Object> secondTab =
(Map<String, Object>) report.getMetaData().get("secondtab");
assertEquals("[FILTERED]", firstTab.get("testfilter1"));
assertEquals("[FILTERED]", firstTab.get("testfilter2"));
assertEquals("secretpassword", firstTab.get("testfilter3"));
Expand Down Expand Up @@ -339,6 +342,7 @@ public void beforeNotify(Report report) {
assertFalse(bugsnag.notify(new Throwable()));
}

@SuppressWarnings("deprecation") // ensures deprecated setEndpoint method still works correctly
@Test
public void testEndpoint() {
Bugsnag bugsnag = new Bugsnag("apikey");
Expand Down Expand Up @@ -454,6 +458,7 @@ public void deliver(Serializer serializer, Object object, Map<String, String> he
Map<String, Object> session = report.getSession();
assertNotNull(session);

@SuppressWarnings("unchecked")
Map<String, Object> handledCounts = (Map<String, Object>) session.get("events");
assertEquals(1, handledCounts.get("handled"));
assertEquals(0, handledCounts.get("unhandled"));
Expand Down Expand Up @@ -486,5 +491,6 @@ public void testUncaughtHandlerModification() throws Throwable {

// Test exception class
private class TestException extends RuntimeException {
private static final long serialVersionUID = -458298914160798211L;
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/bugsnag/ServletCallbackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testRequestMetadataAdded() {
ServletCallback callback = new ServletCallback();
callback.beforeNotify(report);

Map<String, Object> metadata = (Map<String, Object>)report.getMetaData();
Map<String, Object> metadata = report.getMetaData();
assertTrue(metadata.containsKey("request"));

Map<String, Object> request = (Map<String, Object>)metadata.get("request");
Expand Down
7 changes: 0 additions & 7 deletions src/test/java/com/bugsnag/SessionTrackerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ public void enabledReleaseStage() throws Throwable {
assertNotNull(sessionTracker.getSession());
}

@Test(timeout = 200)
public void addManySessions() throws Throwable {
for (int k = 0; k < 1000; k++) {
sessionTracker.startSession(new Date(), false);
}
}

@Test
public void zeroSessionDelivery() throws Throwable {
CustomDelivery sessionDelivery = new CustomDelivery() {
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/bugsnag/util/FilteredMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void testGet() throws Exception {
Object actual = filteredMap.get(KEY_NESTED);
assertTrue(actual instanceof FilteredMap);

@SuppressWarnings("unchecked")
Map<String, Object> nestedMap = (Map<String, Object>) actual;
assertEquals(VAL_UNFILTERED, nestedMap.get(KEY_UNFILTERED));
assertEquals(PLACEHOLDER_FILTERED, nestedMap.get(KEY_FILTERED));
Expand All @@ -125,6 +126,8 @@ public void testValues() throws Exception {

Object nestedObj = values.toArray(new Object[1])[0];
assertTrue(nestedObj instanceof FilteredMap);

@SuppressWarnings("unchecked")
Map<String, Object> nestedMap = (Map<String, Object>) nestedObj;
values = nestedMap.values();

Expand Down Expand Up @@ -157,6 +160,8 @@ public void testEntrySet() throws Exception {
assertTrue(value instanceof FilteredMap);
} else if (key.equals(KEY_UNMODIFIABLE)) {
expectedCount++;

@SuppressWarnings("unchecked")
Map<String, Object> nested = (Map<String, Object>) entry.getValue();
assertEquals(2, nested.entrySet().size());
}
Expand Down

0 comments on commit 188ea20

Please sign in to comment.