Skip to content

Commit 39a587f

Browse files
yuluo-yxtomsun28
andauthored
[bugfix] fix AlertTemplateUtilTest test exception and update code style (apache#1969)
Signed-off-by: yuluo-yx <[email protected]> Co-authored-by: tomsun28 <[email protected]>
1 parent aa3331e commit 39a587f

13 files changed

+10
-22
lines changed

alerter/src/main/java/org/apache/hertzbeat/alert/AlerterProperties.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,5 @@ public static class KafkaProperties {
112112
private String groupId;
113113

114114
}
115-
116115
}
117-
118-
119116
}

alerter/src/main/java/org/apache/hertzbeat/alert/service/AlertDefineImExportService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.io.OutputStream;
2222
import java.util.List;
2323

24-
2524
/**
2625
* Configuration Import Export
2726
*/

alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineAbstractImExportServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.hertzbeat.alert.service.impl;
1919

20-
2120
import cn.afterturn.easypoi.excel.annotation.Excel;
2221
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
2322
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineExcelImExportServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.springframework.stereotype.Service;
4040
import org.springframework.util.StringUtils;
4141

42-
4342
/**
4443
* Configure the import and export EXCEL format
4544
*/
@@ -263,6 +262,4 @@ void writeOs(List<ExportAlertDefineDTO> exportAlertDefineList, OutputStream os)
263262
throw new RuntimeException(e);
264263
}
265264
}
266-
267-
268265
}

alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineJsonImExportServiceImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.hertzbeat.alert.service.impl;
1919

20-
2120
import com.fasterxml.jackson.core.type.TypeReference;
2221
import com.fasterxml.jackson.databind.ObjectMapper;
2322
import java.io.IOException;
@@ -28,7 +27,6 @@
2827
import lombok.extern.slf4j.Slf4j;
2928
import org.springframework.stereotype.Service;
3029

31-
3230
/**
3331
* Configure the import and export JSON format
3432
*/

alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineYamlImExportServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.hertzbeat.alert.service.impl;
1919

20-
2120
import java.io.InputStream;
2221
import java.io.OutputStream;
2322
import java.io.OutputStreamWriter;
@@ -28,7 +27,6 @@
2827
import org.yaml.snakeyaml.DumperOptions;
2928
import org.yaml.snakeyaml.Yaml;
3029

31-
3230
/**
3331
* Configure the import and export Yaml format
3432
*/
@@ -39,7 +37,6 @@ public class AlertDefineYamlImExportServiceImpl extends AlertDefineAbstractImExp
3937
public static final String TYPE = "YAML";
4038
public static final String FILE_SUFFIX = ".yaml";
4139

42-
4340
@Override
4441
public String type() {
4542
return TYPE;

alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,4 @@ private Alert buildAlertData(AlertReport alertReport){
158158
.gmtUpdate(dateTime)
159159
.build();
160160
}
161-
162-
163-
164161
}

alerter/src/main/java/org/apache/hertzbeat/alert/util/AlertTemplateUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public static String render(String template, Map<String, Object> replaceData) {
3838
if (template == null) {
3939
return null;
4040
}
41+
if (replaceData == null) {
42+
log.warn("The replaceData is null.");
43+
return template;
44+
}
4145
try {
4246
Matcher matcher = PATTERN.matcher(template);
4347
StringBuilder builder = new StringBuilder();

alerter/src/main/java/org/apache/hertzbeat/alert/util/DateUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class DateUtil {
2929

3030
private static final String[] DATE_FORMATS = {
3131
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
32-
"yyyy-MM-dd HH:mm:ss"};
32+
"yyyy-MM-dd HH:mm:ss"
33+
};
3334

3435
/**
3536
* convert date to timestamp

alerter/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515

1616
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
17-
org.apache.hertzbeat.alert.config.AlerterAutoConfiguration
17+
org.apache.hertzbeat.alert.config.AlerterAutoConfiguration

0 commit comments

Comments
 (0)