AspectJ Plugin throws UnsupportedOperationException
---------------------------------------------------

         Key: MOJO-200
         URL: http://jira.codehaus.org/browse/MOJO-200
     Project: Mojo
        Type: Bug

  Components: aspectj  
 Environment: Maven 2.0.1
Windows XP Pro SP2

    Reporter: Ralf Quebbemann


AspectJ plugin throws UnsupportedOperationException when executing the command:

mvn clean install site

[INFO] [aspectj:compile {execution: default}]
[INFO] Starting compiling aspects
[INFO] 
----------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] 
----------------------------------------------------------------------------
[INFO] null
[INFO] 
----------------------------------------------------------------------------
[INFO] Trace
java.lang.UnsupportedOperationException
        at 
java.util.Collections$UnmodifiableCollection.addAll(Collections.java:1028)
        at 
org.codehaus.mojo.aspectj.AbstractAjcMojo.createClassPath(AbstractAjcMojo.java:121)
        at 
org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:58)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:432)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:530)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:47
2)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:858)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:729)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:521)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:47
2)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.jav
a:303)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] 
----------------------------------------------------------------------------
[INFO] Total time: 18 seconds
[INFO] Finished at: Fri Dec 30 09:49:50 CET 2005
[INFO] Final Memory: 15M/27M
[INFO] 
----------------------------------------------------------------------------

It seems to be a problem when creating the classpath. I changed the following 
method in "AbstractAjcMojo"

    protected String createClassPath()
    {
        String cp = new String();
        Set classPathElements = project.getDependencyArtifacts();
        classPathElements.addAll(project.getArtifacts());
        Iterator iter = classPathElements.iterator();

    ...
    }

Replaced with:

    protected String createClassPath()
    {
        String cp = new String();
        Set classPathElements = Collections.synchronizedSet(new 
TreeSet(project.getDependencyArtifacts()));
        classPathElements.addAll(project.getArtifacts());
        Iterator iter = classPathElements.iterator();

    ...
    }

This change fixes the problem.

Seems to me, that multiple threads are accessing the set concurrently.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to