Skip to content

Commit

Permalink
Catching exception while checking configuration dependencies (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusoe authored Dec 23, 2021
1 parent 8a30e8a commit 6ce95ab
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rocks.inspectit.ocelot.core.service;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
Expand All @@ -24,6 +25,7 @@
* This class handles the waiting for changes in the configuration.
* If relevant changes to the configuration occur, this class ensures that the service is properly restarted.
*/
@Slf4j
public abstract class DynamicallyActivatableService {

@Autowired
Expand Down Expand Up @@ -103,11 +105,15 @@ synchronized boolean disable() {
synchronized void checkForUpdates(InspectitConfigChangedEvent ev) {
boolean affected = false;
for (Expression exp : configDependencies) {
Object oldVal = exp.getValue(ev.getOldConfig());
Object newVal = exp.getValue(ev.getNewConfig());
boolean isEqual = Objects.equals(oldVal, newVal);
if (!isEqual) {
affected = true;
try {
Object oldVal = exp.getValue(ev.getOldConfig());
Object newVal = exp.getValue(ev.getNewConfig());
boolean isEqual = Objects.equals(oldVal, newVal);
if (!isEqual) {
affected = true;
}
} catch (Exception exception) {
log.error("Exception while evaluating configuration dependencies: {}", exception.getMessage());
}
}
if (affected) {
Expand All @@ -125,7 +131,7 @@ synchronized void checkForUpdates(InspectitConfigChangedEvent ev) {

/**
* The implementation of this method checks if the service should be enabled given a certain configuration.
* When changes to the configuration occur, this method will be used to correctly invoke {@link #doDisable()} and {@link #doEnable()}.
* When changes to the configuration occur, this method will be used to correctly invoke {@link #doDisable()} and {@link #doEnable(InspectitConfig)}.
*
* @param configuration the configuration to check
*
Expand Down

0 comments on commit 6ce95ab

Please sign in to comment.