Skip to content

Commit

Permalink
Merge branch 'master' into add-data-source-support
Browse files Browse the repository at this point in the history
  • Loading branch information
dprzybyl committed Nov 2, 2023
2 parents b708388 + 5075f19 commit f134354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.cognifide.apm.api.scripts.LaunchMode;
import com.cognifide.apm.api.scripts.Script;
import com.cognifide.apm.api.services.RunModesProvider;
import java.util.Date;
import java.util.Set;
import java.util.function.Predicate;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -94,11 +95,14 @@ private static Predicate<Script> withLaunchMode(LaunchMode mode) {
}

private static Predicate<Script> withSchedule() {
return script -> script.getLaunchMode() == LaunchMode.ON_SCHEDULE && script.getLaunchSchedule() != null;
return script -> script.getLaunchMode() == LaunchMode.ON_SCHEDULE
&& script.getLaunchSchedule() != null
&& script.getLaunchSchedule().after(new Date());
}

private static Predicate<Script> withCronExpression() {
return script -> script.getLaunchMode() == LaunchMode.ON_CRON_EXPRESSION && StringUtils.isNotEmpty(script.getLaunchCronExpression());
return script -> script.getLaunchMode() == LaunchMode.ON_CRON_EXPRESSION
&& StringUtils.isNotEmpty(script.getLaunchCronExpression());
}

private static Predicate<Script> enabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void onChange(List<ResourceChange> changes) {
if (onScheduleOrCronExpression(runModesProvider).test(script)) {
registerScript(script, bundleContext);
}
} else if (!Objects.equals(script, registeredScript.script)) {
} else if (!Objects.equals(script, registeredScript.script) || script.getLaunchMode() == LaunchMode.ON_SCHEDULE) {
registeredScript.registration.unregister();
registeredScripts.remove(change.getPath());
if (onScheduleOrCronExpression(runModesProvider).test(script)) {
Expand Down

0 comments on commit f134354

Please sign in to comment.