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

[Bug] WatchFileManagerTest unit test failed #4711

Closed
2 of 3 tasks
Pil0tXia opened this issue Jan 3, 2024 · 0 comments · Fixed by #4716
Closed
2 of 3 tasks

[Bug] WatchFileManagerTest unit test failed #4711

Pil0tXia opened this issue Jan 3, 2024 · 0 comments · Fixed by #4716
Labels
bug Something isn't working

Comments

@Pil0tXia
Copy link
Member

Pil0tXia commented Jan 3, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Environment

Windows

EventMesh version

master

What happened

Unit test failed.

image

image

image

How to reproduce

Execute the test task of the eventmesh-common module in the Gradle sidebar of IDEA.

Debug logs

13:19:10.349 [Thread-6] ERROR org.apache.eventmesh.common.file.WatchFileTask - [WatchFileTask] an exception occurred during file listening : 
java.nio.file.ClosedWatchServiceException: null
	at sun.nio.fs.AbstractWatchService.checkOpen(AbstractWatchService.java:80) ~[?:1.8.0_392]
	at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:117) ~[?:1.8.0_392]
	at org.apache.eventmesh.common.file.WatchFileTask.run(WatchFileTask.java:81) [main/:?]
13:19:10.349 [Thread-6] ERROR org.apache.eventmesh.common.file.WatchFileTask - [WatchFileTask] an exception occurred during file listening : 
java.nio.file.ClosedWatchServiceException: null
	at sun.nio.fs.AbstractWatchService.checkOpen(AbstractWatchService.java:80) ~[?:1.8.0_392]
	at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:117) ~[?:1.8.0_392]
	at org.apache.eventmesh.common.file.WatchFileTask.run(WatchFileTask.java:81) [main/:?]

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@Pil0tXia Pil0tXia added the bug Something isn't working label Jan 3, 2024
pandaapo pushed a commit that referenced this issue Jan 10, 2024
…4716)

* Properly close resources used by WatchFileManagerTest

* Create WatchService without try-with-resources

The WatchService was being prematurely auto-closed, resulting in ClosedWatchService exceptions

* Restructure WatchFileManagerTest.testWatchFile to assert the file change event is detected

* Load properties file prior to creating FileWriter in WatchFileManagerTest

This change ensures the properties in tempConfigFile are loaded into the properties object before the tempConfigFile is cleared by creating the new FileWriter

* Verify onChange is called at least once

Depending on when the WatchService begins monitoring for file changes, it is possible that creating the new FileWriter, which clears the provided file, will trigger an onChange call, in addition to the onChange call triggered by properties.store().

* Close WatchService in WatchFileTask.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant