Skip to content

Commit b7ca7cf

Browse files
committed
refactor(Bugsnag*): rename Event, Error, and Thread to Bugsnag{name} so that the public API doesn't pollute common java.lang classes (and Event)
1 parent b7e42d4 commit b7ca7cf

40 files changed

Lines changed: 229 additions & 230 deletions

bugsnag-spring/src/main/java/com/bugsnag/BugsnagSpringConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class BugsnagSpringConfiguration implements InitializingBean {
2828
Callback springVersionErrorCallback() {
2929
Callback callback = new Callback() {
3030
@Override
31-
public boolean onError(Event report) {
31+
public boolean onError(BugsnagEvent report) {
3232
addSpringRuntimeVersion(report.getDevice());
3333
return true;
3434
}

bugsnag-spring/src/main/java/com/bugsnag/ExceptionClassCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class ExceptionClassCallback implements Callback {
111111
}
112112

113113
@Override
114-
public boolean onError(Event event) {
114+
public boolean onError(BugsnagEvent event) {
115115

116116
HandledState handledState = event.getHandledState();
117117

bugsnag-spring/src/main/java/com/bugsnag/SpringBootConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class SpringBootConfiguration {
1919
Callback springBootVersionErrorCallback() {
2020
Callback callback = new Callback() {
2121
@Override
22-
public boolean onError(Event report) {
22+
public boolean onError(BugsnagEvent report) {
2323
addSpringRuntimeVersion(report.getDevice());
2424
return true;
2525
}

bugsnag-spring/src/test/java/com/bugsnag/NotifierTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
public class NotifierTest {
1313

14-
private Event event;
14+
private BugsnagEvent event;
1515
private Configuration config;
1616
private SessionPayload sessionPayload;
1717

@@ -23,7 +23,7 @@ public class NotifierTest {
2323
@Before
2424
public void setUp() throws Throwable {
2525
config = new Configuration("api-key");
26-
event = new Event(config, new RuntimeException());
26+
event = new BugsnagEvent(config, new RuntimeException());
2727
sessionPayload = new SessionPayload(Collections.<SessionCount>emptyList(), config);
2828
}
2929

bugsnag-spring/src/test/java/com/bugsnag/SpringAsyncTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void setUp() {
5050
public void bugsnagNotifyWhenAsyncVoidReturnTypeException() {
5151
asyncService.throwExceptionVoid();
5252

53-
Event event = verifyAndGetReport(delivery);
53+
BugsnagEvent event = verifyAndGetReport(delivery);
5454

5555
// Assert that the exception was detected correctly
5656
assertEquals("Async void test", event.getExceptionMessage());
@@ -71,7 +71,7 @@ public void bugsnagNotifyWhenAsyncVoidReturnTypeException() {
7171
public void bugsnagNotifyWhenAsyncFutureReturnTypeException() {
7272
asyncService.throwExceptionFuture();
7373

74-
Event event = verifyAndGetReport(delivery);
74+
BugsnagEvent event = verifyAndGetReport(delivery);
7575

7676
// Assert that the exception was detected correctly
7777
assertEquals("Async future test", event.getExceptionMessage());

bugsnag-spring/src/test/java/com/bugsnag/SpringMvcTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void setUp() {
8383
public void bugsnagNotifyWhenUncaughtControllerException() {
8484
callRuntimeExceptionEndpoint();
8585

86-
Event event = verifyAndGetReport(delivery);
86+
BugsnagEvent event = verifyAndGetReport(delivery);
8787

8888
// Assert that the exception was detected correctly
8989
assertEquals("Test", event.getExceptionMessage());
@@ -129,7 +129,7 @@ public void noBugsnagSessionStartedWhenAutoCaptureSessionsFalse() {
129129
public void requestMetadataSetCorrectly() {
130130
callRuntimeExceptionEndpoint();
131131

132-
Event event = verifyAndGetReport(delivery);
132+
BugsnagEvent event = verifyAndGetReport(delivery);
133133

134134
// Check that the context is set to the HTTP method and URI of the endpoint
135135
assertEquals("GET /throw-runtime-exception", event.getContext());
@@ -161,7 +161,7 @@ public void requestMetadataSetCorrectly() {
161161
public void springVersionSetCorrectly() {
162162
callRuntimeExceptionEndpoint();
163163

164-
Event event = verifyAndGetReport(delivery);
164+
BugsnagEvent event = verifyAndGetReport(delivery);
165165

166166
// Check that the Spring version is set as expected
167167
Map<String, Object> deviceMetadata = event.getDevice();
@@ -175,7 +175,7 @@ public void springVersionSetCorrectly() {
175175
public void unhandledTypeMismatchExceptionSeverityInfo() {
176176
callUnhandledTypeMismatchExceptionEndpoint();
177177

178-
Event event = verifyAndGetReport(delivery);
178+
BugsnagEvent event = verifyAndGetReport(delivery);
179179

180180
assertTrue(event.getUnhandled());
181181
assertEquals("info", event.getSeverity());
@@ -187,10 +187,10 @@ public void unhandledTypeMismatchExceptionSeverityInfo() {
187187
@Test
188188
public void unhandledTypeMismatchExceptionCallbackSeverity()
189189
throws IllegalAccessException, NoSuchFieldException {
190-
Event event;
190+
BugsnagEvent event;
191191
Callback callback = new Callback() {
192192
@Override
193-
public boolean onError(Event report) {
193+
public boolean onError(BugsnagEvent report) {
194194
report.setSeverity(Severity.WARNING);
195195
return true;
196196
}
@@ -219,7 +219,7 @@ public boolean onError(Event report) {
219219
public void handledTypeMismatchExceptionUserSeverity() {
220220
callHandledTypeMismatchExceptionUserSeverityEndpoint();
221221

222-
Event event = verifyAndGetReport(delivery);
222+
BugsnagEvent event = verifyAndGetReport(delivery);
223223

224224
assertFalse(event.getUnhandled());
225225
assertEquals("warning", event.getSeverity());
@@ -231,7 +231,7 @@ public void handledTypeMismatchExceptionUserSeverity() {
231231
public void handledTypeMismatchExceptionCallbackSeverity() {
232232
callHandledTypeMismatchExceptionCallbackSeverityEndpoint();
233233

234-
Event event = verifyAndGetReport(delivery);
234+
BugsnagEvent event = verifyAndGetReport(delivery);
235235

236236
assertFalse(event.getUnhandled());
237237
assertEquals("warning", event.getSeverity());

bugsnag-spring/src/test/java/com/bugsnag/SpringScheduledTaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void run() {
7070
// Run the task now and wait for it to finish
7171
scheduler.submit(exampleRunnable).get();
7272

73-
Event event = verifyAndGetReport(delivery);
73+
BugsnagEvent event = verifyAndGetReport(delivery);
7474

7575
// Assert that the exception was detected correctly
7676
assertEquals("Scheduled test", event.getExceptionMessage());

bugsnag-spring/src/test/java/com/bugsnag/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestUtils {
1616
/**
1717
* Verify that a report was received, then capture and return that report
1818
*/
19-
static Event verifyAndGetReport(Delivery delivery) {
19+
static BugsnagEvent verifyAndGetReport(Delivery delivery) {
2020
ArgumentCaptor<Notification> notificationCaptor =
2121
ArgumentCaptor.forClass(Notification.class);
2222
verify(delivery, timeout(100).times(1)).deliver(

bugsnag-spring/src/test/java/com/bugsnag/testapp/springboot/TestController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.bugsnag.Bugsnag;
44

5-
import com.bugsnag.Event;
5+
import com.bugsnag.BugsnagEvent;
66
import com.bugsnag.Severity;
77
import com.bugsnag.callbacks.Callback;
88

@@ -67,7 +67,7 @@ public void handledTypeMismatchExceptionCallbackSeverity() {
6767
} catch (TypeMismatchException ex) {
6868
bugsnag.notify(ex, new Callback() {
6969
@Override
70-
public boolean onError(Event event) {
70+
public boolean onError(BugsnagEvent event) {
7171
event.setSeverity(Severity.WARNING);
7272
return true;
7373
}

bugsnag/src/main/java/com/bugsnag/Bugsnag.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void run() {
122122
}
123123

124124
private void addSessionTrackingShutdownHook() {
125-
Runtime.getRuntime().addShutdownHook(new Thread() {
125+
Runtime.getRuntime().addShutdownHook(new java.lang.Thread() {
126126
@Override
127127
public void run() {
128128
close();
@@ -349,13 +349,13 @@ public void setTimeout(int timeout) {
349349
*
350350
* @param throwable the exception to send to Bugsnag
351351
* @return the report object
352-
* @see Event
353-
* @see #notify(Event)
352+
* @see BugsnagEvent
353+
* @see #notify(BugsnagEvent)
354354
*/
355-
public Event buildReport(Throwable throwable) {
355+
public BugsnagEvent buildReport(Throwable throwable) {
356356
HandledState handledState = HandledState.newInstance(
357357
HandledState.SeverityReasonType.REASON_HANDLED_EXCEPTION);
358-
return new Event(config, throwable, handledState, Thread.currentThread(), featureFlagStore);
358+
return new BugsnagEvent(config, throwable, handledState, java.lang.Thread.currentThread(), featureFlagStore);
359359
}
360360

361361
/**
@@ -411,39 +411,39 @@ public boolean notify(Throwable throwable, Severity severity, Callback callback)
411411

412412
HandledState handledState = HandledState.newInstance(
413413
HandledState.SeverityReasonType.REASON_USER_SPECIFIED, severity);
414-
Event event = new Event(config, throwable, handledState, Thread.currentThread(), featureFlagStore);
414+
BugsnagEvent event = new BugsnagEvent(config, throwable, handledState, java.lang.Thread.currentThread(), featureFlagStore);
415415
return notify(event, callback);
416416
}
417417

418418
/**
419419
* Notify Bugsnag of an exception and provide custom diagnostic data
420420
* for this particular error report.
421421
*
422-
* @param event the {@link Event} object to send to Bugsnag
422+
* @param event the {@link BugsnagEvent} object to send to Bugsnag
423423
* @return true unless the error report was ignored
424-
* @see Event
424+
* @see BugsnagEvent
425425
* @see #buildReport
426426
*/
427-
public boolean notify(Event event) {
427+
public boolean notify(BugsnagEvent event) {
428428
return notify(event, null);
429429
}
430430

431-
boolean notify(Throwable throwable, HandledState handledState, Thread currentThread) {
432-
Event event = new Event(config, throwable, handledState, currentThread, featureFlagStore);
431+
boolean notify(Throwable throwable, HandledState handledState, java.lang.Thread currentThread) {
432+
BugsnagEvent event = new BugsnagEvent(config, throwable, handledState, currentThread, featureFlagStore);
433433
return notify(event, null);
434434
}
435435

436436
/**
437437
* Notify Bugsnag of an exception and provide custom diagnostic data
438438
* for this particular error report.
439439
*
440-
* @param event the {@link Event} object to send to Bugsnag
440+
* @param event the {@link BugsnagEvent} object to send to Bugsnag
441441
* @param reportCallback the {@link Callback} object to run for this Report
442442
* @return false if the error report was ignored
443-
* @see Event
443+
* @see BugsnagEvent
444444
* @see #buildReport
445445
*/
446-
public boolean notify(Event event, Callback reportCallback) {
446+
public boolean notify(BugsnagEvent event, Callback reportCallback) {
447447
if (event == null) {
448448
LOGGER.warn("Tried to call notify with a null Report");
449449
return false;
@@ -675,7 +675,7 @@ SessionTracker getSessionTracker() {
675675
* @return clients which catch uncaught exceptions
676676
*/
677677
public static Set<Bugsnag> uncaughtExceptionClients() {
678-
UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
678+
UncaughtExceptionHandler handler = java.lang.Thread.getDefaultUncaughtExceptionHandler();
679679
if (handler instanceof ExceptionHandler) {
680680
ExceptionHandler bugsnagHandler = (ExceptionHandler) handler;
681681
return Collections.unmodifiableSet(bugsnagHandler.uncaughtExceptionClients());

0 commit comments

Comments
 (0)