Skip to content

Commit a141072

Browse files
authored
fix(eventtemplates): log warning and continue if declarative Event Template already exists (#726)
1 parent c3ee63b commit a141072

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/io/cryostat/events/S3TemplateService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ void onStart(@Observes StartupEvent evt) {
115115
| InvalidXmlException
116116
| InvalidEventTemplateException e) {
117117
logger.error(e);
118+
} catch (IllegalArgumentException e) {
119+
logger.warn(e);
118120
}
119121
});
120122
} catch (IOException e) {
@@ -225,8 +227,7 @@ public Template addTemplate(InputStream stream)
225227
var template = createTemplate(model);
226228
var existing = getTemplates();
227229
if (existing.stream().anyMatch(t -> Objects.equals(t.getName(), template.getName()))) {
228-
throw new IllegalArgumentException(
229-
String.format("Duplicate event template name: %s", template.getName()));
230+
throw new DuplicateTemplateException(template.getName());
230231
}
231232
storage.putObject(
232233
PutObjectRequest.builder()
@@ -357,4 +358,10 @@ private String getAttributeValue(XMLTagInstance node, String valueKey) {
357358
.findFirst()
358359
.get();
359360
}
361+
362+
static class DuplicateTemplateException extends IllegalArgumentException {
363+
DuplicateTemplateException(String templateName) {
364+
super(String.format("Event Template with name \"%s\" already exists", templateName));
365+
}
366+
}
360367
}

0 commit comments

Comments
 (0)