Skip to content

Commit

Permalink
remove Bugsnag.init
Browse files Browse the repository at this point in the history
  • Loading branch information
Pezzah committed Nov 12, 2018
1 parent d8ec1da commit 21815b6
Show file tree
Hide file tree
Showing 21 changed files with 19 additions and 51 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Expand Up @@ -23,9 +23,6 @@ No upgrade steps are required for `bugsnag-java` in this release.
* [Spring] Automatically attach Spring version information to reports
* [Spring] Automatically track sessions for each MVC request

**Deprecation notice**: `Bugsnag.init(...)` is now the preferred way to get an instance of the Bugsnag client
instead of `new Bugsnag(...)`.

See [UPGRADING](UPGRADING.md) for upgrade details and [the docs](https://docs.bugsnag.com/platforms/java/spring) for further information on new functionality.

## 3.3.0 (2018-09-26)
Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.md
Expand Up @@ -20,7 +20,7 @@ If you develop a [Spring Framework](https://spring.io/) application, it is recom
public class BugsnagConfig {
@Bean
public Bugsnag bugsnag() {
return Bugsnag.init("your-api-key-here");
return new Bugsnag("your-api-key-here");
}
}
```
Expand Down
Expand Up @@ -28,7 +28,7 @@ public class TestConfiguration extends AsyncConfigurerSupport implements Schedul

@Bean
public Bugsnag bugsnag() {
return Bugsnag.init("apiKey");
return new Bugsnag("apiKey");
}

@Bean
Expand Down
29 changes: 0 additions & 29 deletions bugsnag/src/main/java/com/bugsnag/Bugsnag.java
Expand Up @@ -49,34 +49,7 @@ public MetaData initialValue() {
* Initialize a Bugsnag client and automatically send uncaught exceptions.
*
* @param apiKey your Bugsnag API key from your Bugsnag dashboard
* @return The Bugsnag client instance
*/
public static Bugsnag init(String apiKey) {
return init(apiKey, true);
}

/**
* Initialize a Bugsnag client.
*
* @param apiKey your Bugsnag API key
* @param sendUncaughtExceptions should we send uncaught exceptions to Bugsnag
* @return The Bugsnag client instance
*/
public static Bugsnag init(String apiKey, boolean sendUncaughtExceptions) {
if (apiKey == null) {
throw new NullPointerException("You must provide a Bugsnag API key");
}

return new Bugsnag(apiKey, sendUncaughtExceptions);
}

/**
* Initialize a Bugsnag client and automatically send uncaught exceptions.
*
* @param apiKey your Bugsnag API key from your Bugsnag dashboard
* @deprecated use {@link Bugsnag#init(String)} instead
*/
@Deprecated
public Bugsnag(String apiKey) {
this(apiKey, true);
}
Expand All @@ -86,9 +59,7 @@ public Bugsnag(String apiKey) {
*
* @param apiKey your Bugsnag API key
* @param sendUncaughtExceptions should we send uncaught exceptions to Bugsnag
* @deprecated use {@link Bugsnag#init(String, boolean)} instead
*/
@Deprecated
public Bugsnag(String apiKey, boolean sendUncaughtExceptions) {
if (apiKey == null) {
throw new NullPointerException("You must provide a Bugsnag API key");
Expand Down
2 changes: 1 addition & 1 deletion bugsnag/src/main/java/com/bugsnag/BugsnagAppender.java
Expand Up @@ -209,7 +209,7 @@ private Throwable extractThrowable(ILoggingEvent event) {
* @return Create a Bugsnag instance with parameters from the logback configuration
*/
private Bugsnag createBugsnag() {
Bugsnag bugsnag = Bugsnag.init(apiKey, false);
Bugsnag bugsnag = new Bugsnag(apiKey, false);
bugsnag.setAutoCaptureSessions(false);

if (appType != null) {
Expand Down
2 changes: 1 addition & 1 deletion bugsnag/src/test/java/com/bugsnag/BugsnagTest.java
Expand Up @@ -33,7 +33,7 @@ public class BugsnagTest {
*/
@Before
public void initBugsnag() {
bugsnag = Bugsnag.init("apikey");
bugsnag = new Bugsnag("apikey");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion bugsnag/src/test/java/com/bugsnag/ExceptionTest.java
Expand Up @@ -49,7 +49,7 @@ public void testClassOverride() {

@Test
public void testReportCallback() {
Bugsnag bugsnag = Bugsnag.init("apikey");
Bugsnag bugsnag = new Bugsnag("apikey");
bugsnag.setDelivery(new Delivery() {
@Override
public void deliver(Serializer serializer, Object object, Map<String, String> headers) {
Expand Down
2 changes: 1 addition & 1 deletion bugsnag/src/test/java/com/bugsnag/ServletCallbackTest.java
Expand Up @@ -33,7 +33,7 @@ public class ServletCallbackTest {
*/
@Before
public void setUp() {
bugsnag = Bugsnag.init("apikey", false);
bugsnag = new Bugsnag("apikey", false);
bugsnag.setDelivery(null);

HttpServletRequest request = mock(HttpServletRequest.class);
Expand Down
2 changes: 1 addition & 1 deletion bugsnag/src/test/java/com/bugsnag/ThreadMetaDataTest.java
Expand Up @@ -23,7 +23,7 @@ public class ThreadMetaDataTest {
*/
@Before
public void swapDelivery() {
bugsnag = Bugsnag.init("testapikey");
bugsnag = new Bugsnag("testapikey");
originalDelivery = bugsnag.getDelivery();
delivery = new StubNotificationDelivery();
bugsnag.setDelivery(delivery);
Expand Down
2 changes: 1 addition & 1 deletion examples/servlet/README.md
Expand Up @@ -2,7 +2,7 @@

Demonstrates how to use Bugsnag in a Servlet-based Java application.

1. Open `ExampleServlet` and alter the value of `bugsnag = Bugsnag.init("YOUR-API-KEY");` to match your API key
1. Open `ExampleServlet` and alter the value of `bugsnag = new Bugsnag("YOUR-API-KEY");` to match your API key

2. Build the app

Expand Down
Expand Up @@ -18,7 +18,7 @@ public class ErrorHandler extends HttpServlet {
* Error handler to report the error to Bugsnag
*/
public ErrorHandler() {
bugsnag = Bugsnag.init("YOUR-API-KEY");
bugsnag = new Bugsnag("YOUR-API-KEY");
bugsnag.setProjectPackages("com.bugsnag.example");
}

Expand Down
Expand Up @@ -19,7 +19,7 @@ public class ExampleServlet extends HttpServlet {
* Simple servlet example
*/
public ExampleServlet() {
bugsnag = Bugsnag.init("YOUR-API-KEY");
bugsnag = new Bugsnag("YOUR-API-KEY");
bugsnag.setProjectPackages("com.bugsnag.example");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/README.md
Expand Up @@ -2,7 +2,7 @@

Demonstrates how to use Bugsnag in a plain Java application.

1. Open `ExampleApp` and alter the value of `bugsnag = Bugsnag.init("YOUR-API-KEY");` to match your API key
1. Open `ExampleApp` and alter the value of `bugsnag = new Bugsnag("YOUR-API-KEY");` to match your API key

2. Build the app

Expand Down
Expand Up @@ -10,7 +10,7 @@
public class ExampleApp {
public static void main(String[] args) throws InterruptedException {
// Create a Bugsnag client
Bugsnag bugsnag = Bugsnag.init("YOUR-API-KEY");
Bugsnag bugsnag = new Bugsnag("YOUR-API-KEY");

// Set some diagnostic data which will not change during the
// lifecycle of the application
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-web/README.md
Expand Up @@ -2,7 +2,7 @@

Demonstrates how to use Bugsnag in a Spring Boot web based Java application.

1. Open `Config` and alter the value of `bugsnag = Bugsnag.init("YOUR-API-KEY");` to match your API key
1. Open `Config` and alter the value of `bugsnag = new Bugsnag("YOUR-API-KEY");` to match your API key

2. Run the app

Expand Down
Expand Up @@ -18,7 +18,7 @@ public class Config {
@Bean
public Bugsnag bugsnag() {
// Create a Bugsnag client
Bugsnag bugsnag = Bugsnag.init("YOUR-API-KEY");
Bugsnag bugsnag = new Bugsnag("YOUR-API-KEY");

// Set some diagnostic data which will not change during the
// lifecycle of the application
Expand Down
2 changes: 1 addition & 1 deletion examples/spring/README.md
Expand Up @@ -2,7 +2,7 @@

Demonstrates how to use Bugsnag in a Spring Boot console application.

1. Open `Config` and alter the value of `bugsnag = Bugsnag.init("YOUR-API-KEY");` to match your API key
1. Open `Config` and alter the value of `bugsnag = new Bugsnag("YOUR-API-KEY");` to match your API key

2. Run the app

Expand Down
Expand Up @@ -18,7 +18,7 @@ public class Config {
@Bean
public Bugsnag bugsnag() {
// Create a Bugsnag client
Bugsnag bugsnag = Bugsnag.init("YOUR-API-KEY");
Bugsnag bugsnag = new Bugsnag("YOUR-API-KEY");

// Set some diagnostic data which will not change during the
// lifecycle of the application
Expand Down
Expand Up @@ -67,7 +67,7 @@ private void setupBugsnag() {

LOGGER.info("using " + path + " to send Bugsnags");

bugsnag = Bugsnag.init(apiKey, true);
bugsnag = new Bugsnag(apiKey, true);
bugsnag.setEndpoints(path, path);
}

Expand Down
Expand Up @@ -24,7 +24,7 @@ public class BugsnagConfig {

@Bean
public Bugsnag bugsnag() {
Bugsnag bugsnag = Bugsnag.init(bugsnagApiKey);
Bugsnag bugsnag = new Bugsnag(bugsnagApiKey);
bugsnag.setEndpoints(bugsnagEndpoint, bugsnagEndpoint);
bugsnag.setAutoCaptureSessions(autoCaptureSessions);
bugsnag.setReleaseStage("production");
Expand Down
Expand Up @@ -19,7 +19,7 @@ public class Config {

@Bean
public Bugsnag bugsnag() {
Bugsnag bugsnag = Bugsnag.init(bugsnagApiKey);
Bugsnag bugsnag = new Bugsnag(bugsnagApiKey);
bugsnag.setEndpoints(bugsnagEndpoint, bugsnagEndpoint);
bugsnag.setReleaseStage("production");
bugsnag.setAppVersion("1.0.0");
Expand Down

0 comments on commit 21815b6

Please sign in to comment.