[jboss-jira] [JBoss JIRA] (JBVFS-188) TimedCachePolicy using unsynchronized Map by default

David Lloyd (JIRA) issues at jboss.org
Thu Mar 1 10:26:01 EST 2018


     [ https://issues.jboss.org/browse/JBVFS-188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Lloyd resolved JBVFS-188.
-------------------------------
    Resolution: Out of Date


> TimedCachePolicy using unsynchronized Map by default
> ----------------------------------------------------
>
>                 Key: JBVFS-188
>                 URL: https://issues.jboss.org/browse/JBVFS-188
>             Project: JBoss VFS
>          Issue Type: Bug
>          Components: Release
>    Affects Versions: 2.2.0.SP1
>            Reporter: Keiichi Sato
>
> TimedCachePolicy should be created with synchronized Map by default. If TimedCachePolicy is created unsynchronized Map, ConcurrentModificationException occurs on TimedCachePolicy.getValidKeys() method.
> {noformat}
> 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)
> {noformat}
> When JBoss starts with the default configuration, the following output in boot.log.
> {noformat}
> 21:19:20,173 DEBUG [IterableTimedVFSCache] Creating timed cache policy, lifetime: null, threadSafe: true, resolution: null
> {noformat}
> This does not mean TimedCachePolicy is threadSafe
> {code:title=http://anonsvn.jboss.org/repos/jbossas/projects/vfs/tags/2.2.0.SP1/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java|borderStyle=solid}
>    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 --
> {code}
> If defaultLifetime and resolution are null, TimedCachePolicy is created using the default constructor. The default constructor is as the following.
> {code:title=http://anonsvn.jboss.org/repos/common/common-core/tags/2.2.18.GA/src/main/java/org/jboss/util/TimedCachePolicy.java|borderStyle=solid}
>    public TimedCachePolicy() 
>    {
>       this(30*60, false, 0);
>    }
> {code}
> The default constructor specifies threadSafe to false.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list