Skip to content

INT-4185: Fix FileReadingMessageSource for Java 6 #2004

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

Closed
wants to merge 2 commits into from

Conversation

artembilan
Copy link
Member

JIRA: https://jira.spring.io/browse/INT-4185

Even if WatchEventType doesn't expose Java 7 API, its instantiation leads to the StandardWatchEventKinds object which already isn't Java 6

  • Move this.watchEvents = new WatchEventType[] { WatchEventType.CREATE } to the ctor and guard it with the ClassUtils.isPresent("java.nio.file.WatchService")

Tested on Java 6 locally

JIRA: https://jira.spring.io/browse/INT-4185

Even if `WatchEventType` doesn't expose Java 7 API, its instantiation leads to the `StandardWatchEventKinds` object which already isn't Java 6

* Move `this.watchEvents = new WatchEventType[] { WatchEventType.CREATE }` to the ctor and guard it with the `ClassUtils.isPresent("java.nio.file.WatchService")`
@@ -161,6 +165,9 @@ public FileReadingMessageSource(int internalQueueCapacity) {
public FileReadingMessageSource(Comparator<File> receptionOrderComparator) {
this.toBeReceived = new PriorityBlockingQueue<File>(
DEFAULT_INTERNAL_QUEUE_CAPACITY, receptionOrderComparator);
if (WATCH_SERVICE_PRESENT) {
this.watchEvents = new WatchEventType[] { WatchEventType.CREATE };
}
Copy link
Contributor

Choose a reason for hiding this comment

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

else {
    this.useWatchService = false;
}

Also, need to prevent setting to true (perhaps events too) - and reflect that in the javadocs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah! Agree about Assert.state() in the setUseWatchService(), but not sure what that event should mean...

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean add an assertion in setWatchEvents() too.

@garyrussell
Copy link
Contributor

Looks like you missed my request to force useWatchService to false for Java 6.

If you agree, I can fix on merge.

@garyrussell
Copy link
Contributor

Oops - sorry - it's false by default 😄

@artembilan
Copy link
Member Author

it's false by default

Eh... That was my point 😉

@garyrussell
Copy link
Contributor

Merged as 6a51da6

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