Uploaded image for project: 'JBoss VFS'
  1. JBoss VFS
  2. JBVFS-188

TimedCachePolicy using unsynchronized Map by default

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • 2.2.0.SP1
    • Release
    • None
    • Hide

      Specify jboss.vfs.cache.TimedPolicyCaching.lifetime and jboss.vfs.cache.TimedPolicyCaching.resolution system properties

      Show
      Specify jboss.vfs.cache.TimedPolicyCaching.lifetime and jboss.vfs.cache.TimedPolicyCaching.resolution system properties

      TimedCachePolicy should be created with synchronized Map by default. If TimedCachePolicy is created unsynchronized Map, ConcurrentModificationException occurs on TimedCachePolicy.getValidKeys() method.

      java.util.ConcurrentModificationException
              at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810)
              at java.util.HashMap$EntryIterator.next(HashMap.java:851)
              at java.util.HashMap$EntryIterator.next(HashMap.java:849)
              at org.jboss.util.TimedCachePolicy.getValidKeys(TimedCachePolicy.java:364)
              at org.jboss.virtual.plugins.cache.IterableTimedVFSCache.findContext(IterableTimedVFSCache.java:65)
              at org.jboss.virtual.plugins.cache.CombinedVFSCache.findContext(CombinedVFSCache.java:116)
              at org.jboss.virtual.plugins.registry.DefaultVFSRegistry.getFile(DefaultVFSRegistry.java:148)
              at org.jboss.virtual.VFS.getRoot(VFS.java:243)
              at org.jboss.virtual.VFS.getRoot(VFS.java:313)
      

      When JBoss starts with the default configuration, the following output in boot.log.

      21:19:20,173 DEBUG [IterableTimedVFSCache] Creating timed cache policy, lifetime: null, threadSafe: true, resolution: null
      

      This does not mean TimedCachePolicy is threadSafe

         protected TimedCachePolicy createCachePolicy()
         -- snip --
            log.debug("Creating timed cache policy, lifetime: " + defaultLifetime + ", threadSafe: " + threadSafe + ", resolution: " + resolution);
      
            TimedCachePolicy tcp;
            if (defaultLifetime == null)
               tcp = new TimedCachePolicy();
            else if (resolution != null)
               tcp = new TimedCachePolicy(defaultLifetime, threadSafe, resolution);
            else
               tcp = new TimedCachePolicy(defaultLifetime);
         -- snip --
      

      If defaultLifetime and resolution are null, TimedCachePolicy is created using the default constructor. The default constructor is as the following.

      The default constructor specifies threadSafe to false.

            Unassigned Unassigned
            ksato_jira Keiichi Sato (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: