[jboss-jira] [JBoss JIRA] (JBVFS-188) TimedCachePolicy using unsynchronized Map by default
Keiichi Sato (JIRA)
jira-events at lists.jboss.org
Thu Jun 27 03:15:21 EDT 2013
[ https://issues.jboss.org/browse/JBVFS-188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Keiichi Sato updated JBVFS-188:
-------------------------------
Description:
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.
was:
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 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.
> TimedCachePolicy using unsynchronized Map by default
> ----------------------------------------------------
>
> Key: JBVFS-188
> URL: https://issues.jboss.org/browse/JBVFS-188
> Project: JBoss VFS
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Release
> Affects Versions: 2.2.0.SP1
> Reporter: Keiichi Sato
> Assignee: David Lloyd
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list