Browse Source

Fix alert server NullPointerException (#948) (#953)

```
AlertServer.getInstance(alertDao)
```
alertDao param solved this
pull/2/head
gary 5 years ago committed by lgcareer
parent
commit
6acf8c6ad8
  1. 11
      escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java
  2. 2
      escheduler-api/src/main/java/cn/escheduler/api/CombinedApplicationServer.java

11
escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java

@ -39,22 +39,21 @@ public class AlertServer implements CommandLineRunner {
/**
* Alert Dao
*/
@Autowired
private AlertDao alertDao;
private AlertSender alertSender;
private static volatile AlertServer instance;
public AlertServer() {
public AlertServer(AlertDao alertDao) {
this.alertDao = alertDao;
}
public static AlertServer getInstance(){
public static AlertServer getInstance(AlertDao alertDao){
if (null == instance) {
synchronized (AlertServer.class) {
if(null == instance) {
instance = new AlertServer();
instance = new AlertServer(alertDao);
}
}
}
@ -83,7 +82,7 @@ public class AlertServer implements CommandLineRunner {
@Override
public void run(String... strings) throws Exception {
AlertServer alertServer = AlertServer.getInstance();
AlertServer alertServer = AlertServer.getInstance(alertDao);
alertServer.start();
}
}

2
escheduler-api/src/main/java/cn/escheduler/api/CombinedApplicationServer.java

@ -51,7 +51,7 @@ public class CombinedApplicationServer extends SpringBootServletInitializer {
LoggerServer server = new LoggerServer();
server.start();
AlertServer alertServer = AlertServer.getInstance();
AlertServer alertServer = AlertServer.getInstance(alertDao);
alertServer.start();
}
}

Loading…
Cancel
Save