Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-122

[vfs] Synchronization issue in SoftRefFilesCache

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 2.0
    • None
    • Sun Solaris, JDK 1.5.0_08

    Description

      I am using Commons VFS 1.0 RC8, and I believe I have found a
      synchronization problem in SoftRefFilesCache.java. My system
      occasionally exhibits high CPU usage in a thread with the stack shown
      below [1]. The problem method is a HashMap.put at line 155 – though I
      think the line number is actually 156, since 155 is a TreeMap.put.

      Access to the refReverseMap is not synchronized (nor is the map itself
      synchronized) which I believe is the problem. On multi-cpu machines,
      this can cause race conditions in HashMap.

      [1] Thread stack:

      "Thread-28" prio=10 tid=0x00f56090 nid=0x34 runnable
      [0xa787d000..0xa787f8f0]
      at java.util.HashMap.put(HashMap.java:420)
      at org.apache.commons.vfs.cache.SoftRefFilesCache.putFile(SoftRefFilesCache.java:155)

      • locked <0xb7a09558> (a java.util.TreeMap)
        at org.apache.commons.vfs.provider.AbstractFileSystem.putFileToCache(AbstractFileSystem.java:163)
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:306)
      • locked <0xb791bfe8> (a org.apache.commons.vfs.provider.local.LocalFileSystem)
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:264)
      • locked <0xb791bfe8> (a org.apache.commons.vfs.provider.local.LocalFileSystem)
        at org.apache.commons.vfs.provider.AbstractFileSystem.getRoot(AbstractFileSystem.java:239)
        at org.apache.commons.vfs.provider.AbstractFileObject.getParent(AbstractFileObject.java:485)
        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:466)
        at org.apache.commons.vfs.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1148)
        at org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:367)
        at org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:350)
        [...]

      Attachments

        Activity

          People

            Unassigned Unassigned
            rocketraman Raman Gupta
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: