Skip to content

Commit bcf531b

Browse files
committed
cleanup
1 parent b437f49 commit bcf531b

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

src/main/java/io/cryostat/rules/Rules.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020
import java.nio.file.Files;
2121
import java.util.List;
22-
import java.util.Objects;
2322

2423
import io.cryostat.ConfigProperties;
2524
import io.cryostat.expressions.MatchExpression;
@@ -71,12 +70,6 @@ void onStart(@Observes StartupEvent evt) {
7170
Files.walk(dir)
7271
.filter(Files::isRegularFile)
7372
.filter(Files::isReadable)
74-
.peek(
75-
p ->
76-
logger.tracev(
77-
"Processing declarative Automated Rule definition at"
78-
+ " {}",
79-
p))
8073
.forEach(this::processDeclarativeRule);
8174
} catch (IOException e) {
8275
logger.error(e);
@@ -87,24 +80,17 @@ private void processDeclarativeRule(java.nio.file.Path path) {
8780
try (var is = new BufferedInputStream(Files.newInputStream(path))) {
8881
var declarativeRule = mapper.readValue(is, Rule.class);
8982
logger.tracev(
90-
"Processing eclarative Automated" + " Rule with name \"{}\"",
91-
declarativeRule.name);
83+
"Processing declarative Automated Rule with name \"{}\" at {}",
84+
declarativeRule.name,
85+
path);
9286
var exists = Rule.find("name", declarativeRule.name).count() != 0;
9387
if (exists) {
94-
var existingRule = Rule.<Rule>find("name", declarativeRule.name).singleResult();
95-
// remove for equality check. The declarative rule is not expected to have a
96-
// database ID yet existingRule.id = null;
97-
if (Objects.equals(declarativeRule, existingRule)) {
98-
return;
99-
}
100-
logger.debugv(
101-
"Rule with name \"{}\" already exists in database. Replacing with"
102-
+ " declarative rule at {}. Previous definition:\n"
103-
+ "{}",
88+
logger.tracev(
89+
"Rule with name \"{}\" already exists in database. Skipping declarative"
90+
+ " rule at {}",
10491
declarativeRule.name,
105-
path,
106-
mapper.writeValueAsString(existingRule));
107-
existingRule.delete();
92+
path);
93+
return;
10894
}
10995
declarativeRule.persist();
11096
} catch (IOException ioe) {

0 commit comments

Comments
 (0)