Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
improve code as RuleUnitInstance is AutoCloseable.
Browse files Browse the repository at this point in the history
  • Loading branch information
aasaru committed Oct 27, 2023
1 parent f1354bd commit 753943a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public void test() {
LOG.info("Creating RuleUnit");
MeasurementUnit measurementUnit = new MeasurementUnit();

RuleUnitInstance<MeasurementUnit> instance = RuleUnitProvider.get().createRuleUnitInstance(measurementUnit);
try {
try (RuleUnitInstance<MeasurementUnit> instance = RuleUnitProvider.get().createRuleUnitInstance(measurementUnit)) {
LOG.info("Insert data");
measurementUnit.getMeasurements().add(new Measurement("color", "red"));
measurementUnit.getMeasurements().add(new Measurement("color", "green"));
Expand All @@ -74,8 +73,6 @@ public void test() {
assertTrue("contains red", measurementUnit.getControlSet().contains("red"));
assertTrue("contains green", measurementUnit.getControlSet().contains("green"));
assertTrue("contains blue", measurementUnit.getControlSet().contains("blue"));
} finally {
instance.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public void test() {
LOG.info("Creating RuleUnit");
MeasurementUnit measurementUnit = new MeasurementUnit();

RuleUnitInstance<MeasurementUnit> instance = RuleUnitProvider.get().createRuleUnitInstance(measurementUnit);
try {
try (RuleUnitInstance<MeasurementUnit> instance = RuleUnitProvider.get().createRuleUnitInstance(measurementUnit)) {
LOG.info("Insert data");
measurementUnit.getMeasurements().add(new Measurement("color", "red"));
measurementUnit.getMeasurements().add(new Measurement("color", "green"));
Expand All @@ -54,8 +53,6 @@ public void test() {
assertTrue("contains red", measurementUnit.getControlSet().contains("red"));
assertTrue("contains green", measurementUnit.getControlSet().contains("green"));
assertTrue("contains blue", measurementUnit.getControlSet().contains("blue"));
} finally {
instance.close();
}
}
}

0 comments on commit 753943a

Please sign in to comment.