[
https://issues.apache.org/jira/browse/VFS-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14000923#comment-14000923
]
Bernd Eckenfels commented on VFS-504:
-------------------------------------
Hm, not sure this is a bug. Why do you start 2 threads in the first place and
register two listeners? I will downgrade this bug. Can you maybe add a complete
test program so I dont have to code my own to debug it?
> Duplicate notifications if there are multiple subscription to same file
> -----------------------------------------------------------------------
>
> Key: VFS-504
> URL: https://issues.apache.org/jira/browse/VFS-504
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Scott.Wu
> Priority: Minor
>
> I initiate 2 threads to monitor same file. I hope to get 2 notifications if I
> changed file, but finally I got 4. I think the root cause is the listener is
> bound to file object, but event will be fired by filemonitor, each monitor
> will point to same file which have 2 listeners.
> // main process
> for (int i = 0; i < 2; i++) {
> Thread thread = new Thread(new Runnable() {
> public void run() {
> try {
> IPAdapterFileMonitor monitor =
> IPAdapterFileMonitor.getInstance();
> monitor.startMonitor();
> } catch (FileSystemException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> });
> thread.start();
> }
> //method in thread.
> public void startMonitor() throws FileSystemException{
> DefaultFileMonitor fm = new DefaultFileMonitor(new
> IPAdapterFileListener());
> fm.addFile(targetFile);
> fm.start();
> System.out.println(Thread.currentThread().getId());
> }
--
This message was sent by Atlassian JIRA
(v6.2#6252)