gmuecke / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

VFS scan is not thread-safe #167

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run multiple threads with VFS scan

What is the expected output? What do you see instead?

Caused by: java.util.ConcurrentModificationException
    at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
    at java.util.AbstractList$Itr.next(AbstractList.java:343)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:96)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:91)
    at org.reflections.Reflections.scan(Reflections.java:231)
    at org.reflections.Reflections.scan(Reflections.java:204)
    at org.reflections.Reflections.<init>(Reflections.java:129)

What version of the product are you using? On what operating system?

0.9.8 / 0.9.9-RC1

Original issue reported on code.google.com by david.ca...@gmail.com on 7 Jan 2014 at 9:29

GoogleCodeExporter commented 8 years ago
The code :

Vfs.addDefaultURLTypes(new VfsUrlType());

final Reflections reflections = new Reflections(
        new ConfigurationBuilder()
                .filterInputsBy(
                        new FilterBuilder().include(FilterBuilder
                                .prefix(packageName)))
                .setUrls(ClasspathHelper.forPackage(packageName))
                .setScanners(new SubTypesScanner(false),
                        new TypeAnnotationsScanner(),
                        new ResourcesScanner()));

return reflections;

Original comment by david.ca...@gmail.com on 7 Jan 2014 at 9:31

GoogleCodeExporter commented 8 years ago
This is not clear. 
Are you calling Vfs.addDefaultURLTypes from multiple threads in the same VM, 
while scan is ongoing?
Are you trying to do a single parallel scan?
org.reflections.vfs.Vfs#defaultUrlTypes should not be changing when scan is 
happening.

Original comment by ronm...@gmail.com on 7 Jan 2014 at 10:22

GoogleCodeExporter commented 8 years ago
There is 2 parrallels EJB calls, calling the code a million times each, working 
in the same VM (JBoss AS 7.2).

Original comment by david.ca...@gmail.com on 7 Jan 2014 at 2:10

GoogleCodeExporter commented 8 years ago
there you go. scan once, query anywhere.

Original comment by ronm...@gmail.com on 7 Jan 2014 at 2:16

GoogleCodeExporter commented 8 years ago
I cannot scan once beacause "packageName" is a variable.

Original comment by david.ca...@gmail.com on 7 Jan 2014 at 5:24