[ http://jira.codehaus.org/browse/MPLUGIN-60?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vincent Siveton closed MPLUGIN-60. ---------------------------------- Assignee: Vincent Siveton Resolution: Fixed Patch not applied in r613484. Using: {noformat} new ArrayList( Collections.singletonList( string ) ); {noformat} > MavenProjectStub uses immutable collections for modifiable data > --------------------------------------------------------------- > > Key: MPLUGIN-60 > URL: http://jira.codehaus.org/browse/MPLUGIN-60 > Project: Maven 2.x Plugin Tools > Issue Type: Bug > Environment: Maven 2.0.7, JDK 1.5.0_12, WinXP, > maven-testing-harness:1.1 > Reporter: Benjamin Bentmann > Assignee: Vincent Siveton > Priority: Minor > Attachments: immutable-lists.patch > > > For example, calling MavenProjectStub.addCompileSourceRoot() twice causes the > following stack trace > {code} > java.lang.UnsupportedOperationException > at java.util.AbstractList.add(AbstractList.java:151) > at java.util.AbstractList.add(AbstractList.java:89) > at > org.apache.maven.plugin.testing.stubs.MavenProjectStub.addCompileSourceRoot(MavenProjectStub.java:328) > {code} > This is caused by the usage of Collections.singletonList() in various methods > to initialize modifiable collection members. However, singletonList() returns > an immutable collection as stated in its javadoc. > The attached patch should fix this. Besides, the patch uses eager > initialization for the collections such that getters like > getCompileSourceRoots() return non-null data right from the beginning. This > makes the stub more consistent with the behavior of MavenProject. > Apropos MavenProject: I wonder why many (if not all) methods inherited from > MavenProject are overriden by MavenProjectStub. For instance, > MavenProject.addCompileSourceRoot() already provides (non-trivial) management > of the source root collection. The stub in turn badly overwrites this, making > the tests behave differently than during a real build while apparently not > providing any more features to the unit tests. Likewise I cannot quite > understand why methods like getDependencies() are overwritten with noops > while the MavenProject's implementation nicely delegates to the model. -- 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