Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ManualSchedulerBuilder uses provided SchedulerListeners #617

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mikhaildruzhinin
Copy link

@mikhaildruzhinin mikhaildruzhinin commented Jan 31, 2025

Brief, plain english overview of your changes here

Made ManualSchedulerBuilder use provided SchedulerListeners instead of a hard coded list. Also fixed ManualScheduler.registerSchedulerListener() throwing an unsupported operation exception.

Fixes

#532

Reminders

  • Added/ran automated tests
  • Update README and/or examples
  • Ran mvn spotless:apply

cc @kagkarlsson

@mikhaildruzhinin
Copy link
Author

@kagkarlsson hi! Any chance you could look at this? :)

Copy link
Owner

@kagkarlsson kagkarlsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing! 🙏
I have a couple of suggestions..

@@ -58,6 +66,7 @@ public void onExecutionStart(CurrentlyExecuting currentlyExecuting) {
});
}

@SuppressWarnings("CodeBlock2Expr")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this... I think maybe just drop these.. (or put it on class-level at least.. )

Comment on lines +479 to 483

public SchedulerListeners getSchedulerListeners() {
return this.schedulerListeners;
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Comment on lines +25 to +36
private final SchedulerListener listener =
new SchedulerListener() {

@Override
public void onExecutionScheduled(TaskInstanceId taskInstanceId, Instant executionTime) {
LOG.info("onExecutionScheduled()");
}

@Override
public void onExecutionStart(CurrentlyExecuting currentlyExecuting) {
LOG.info("onExecutionStart()");
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use SchedulerListener.NOOP instead of defining this one..

Comment on lines +65 to +71
public void register_scheduler_listener() {
LOG.info("register_scheduler_listener()");

ManualScheduler scheduler = TestHelper.createManualScheduler(postgres.getDataSource()).build();

assertDoesNotThrow(() -> scheduler.registerSchedulerListener(listener));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the case previously that this method threw an exception?

Comment on lines +25 to +28
private final SchedulerListener listener =
new SchedulerListener() {

@Override
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOOP listener?

Comment on lines +65 to +74
public void manual_scheduler_listener() {
LOG.info("manual_scheduler_add_listener()");

ManualScheduler scheduler =
TestHelper.createManualScheduler(postgres.getDataSource())
.addSchedulerListener(listener)
.build();

assertThat(scheduler.getSchedulerListeners().getSchedulerListeners(), hasItem(listener));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly a "better" test, or at least one not requiring the method scheduler.getSchedulerListeners() is to attach a listener, run an execution, and verifying that the listener was called (NOOP will not work for that case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants