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

ISPN-15916 Certificate reloading #12359

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tristantarrant
Copy link
Member

@tristantarrant tristantarrant added this to the 15.0.4.Final milestone May 8, 2024
private static FileWatcher INSTANCE;

private final Thread thread;
private final WatchService watchService;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I've modified it to use plain last modified time

public void run() {
while (running) {
try {
Thread.sleep(SLEEP);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be making use of a ScheduledExecutorService and in the case of the server should we be creating this via NamedExecutorsFactory?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is also used by the client.

/**
* @since 15.0
*/
public class FileWatcher implements Runnable {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to use a WatchService instead? https://docs.oracle.com/javase/tutorial/essential/io/notification.html It should theoretically be more lightweight (don't have to check all registered files) and more responsive when file system supports (no sleeps required).

Copy link
Member Author

Choose a reason for hiding this comment

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

The initial implementation did use that, but read #12359 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes. Sorry, I only looked at the code not the prior comments :D

private volatile boolean running = true;

public static synchronized void watch(Path path, Consumer<Path> callback) throws IOException {
if (INSTANCE == null) {
Copy link
Member

Choose a reason for hiding this comment

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

If we keep this class, this can be done with initialization on demand idiom or enum singleton instead, removing the need for synchronization (especially since you are using a CHM).

@wburns wburns changed the title ISPN-15974 Certificate reloading ISPN-15916 Certificate reloading May 17, 2024
@ryanemerson
Copy link
Contributor

@tristantarrant This is breaking CI, there's also @wburns comment that needs addressing.

@tristantarrant
Copy link
Member Author

@tristantarrant This is breaking CI, there's also @wburns comment that needs addressing.

The first few runs of this PR in CI were broken because the PolarionJUnitXMLWriter imported a TestNG class, and since I cleaned up the dependencies a bit, this was cause a CNFE.
Now it's hanging in the BackupIT :)

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