jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2 & 3
  • MNG-4022

Incorrect merge behavior using profile driven plugin configuration

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.9
  • Fix Version/s: 3.0-beta-1
  • Component/s: Profiles
  • Labels:
    None
  • Environment:
    Fedora 10 x86_64, not a factor
  • Complexity:
    Intermediate
  • Testcase included:
    yes

Description

Plugin configurations are not merged correctly when contained inside a profile. The attached example demonstrates a failure where the parent contains the configuration, and the child contains the execution. There is no configuration whatsoever in the child. The circumstances required to trigger this are:

  • Configuration contains a list of at least 2 complex elements.
  • Configuration is inside a profile. This does not happen outside the profile
  • The first element in the list contains parameters that the last element does not contain, e.g.:
    <foos>
    <foo>
    <name>first</name>
    </foo>
    <foo />
    <foo />
    </foos>

In this example, there should be a list of three Foo elements. The first should have name="first" and the last two should have name=null. In reality, the second element will have name=null, but the third will have name="first". This behavior holds for all parameters in the first element that do not exist in the last element.

The attached example includes a test plugin with an Element object that demonstrates this behavior.

I have traced down the cause and have some high level ideas about the fix, but I have not coded a patch.

I think there are two bugs that meet under these circumstances to cause the configuration corruption. Certainly there are multiple opportunities to make this pom configuration work as expected.

First, there is no configuration in the child. Why should maven even attempt a merge? I ran maven through the debugger to get a better understanding of the sequence of events. Maven sources the parent pom and the child pom. When the child pom is sourced, it contains the full configuration exactly as it exists in the parent. Then an attempt is made to merge these identical configurations. Maven has the chance to avoid this issue by recognizing that the configuration element does not exist at all in the child and simply inheriting that as is from the parent.

The other bug is not in Maven. It is in Xpp3Dom (http://fisheye.codehaus.org/browse/plexus/plexus-utils/tags/plexus-utils-1.5.1/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java?r=4475#l346). Notice that it iterates over the list of recessive children (from the parent pom) linearly and attempts to do a map-based lookup for the corresponding element in the dominant children (from the child pom). This works fine when you have a composition of several complex types, but it fails when there is a sequence of the identical types. From a bit more abstract perspective, if Xpp3Dom is attempting to merge two identical Xpp3Doms, I would expect the result to be the identity rather than data corruption.

I have not done the research to understand why profile plugins go through this path inside Xpp3Dom but non-profile plugins apparently don't. There may also be other situations which are affected. I have not tried using a pluginManagement element for instance.

Lastly, there is something of a workaround. You can tell Xpp3Dom not to merge by setting the self.combine attribute:
<configuration self.combine="override">
This tells Xpp3Dom to ignore the recessive Xpp3Dom (parent) and just use the dominant (child) which seems odd given that there is no child configuration. However, it will work if you don't have any real merging needs.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    maven-plugin-merge.zip
    05/Feb/09 11:06 AM
    13 kB
    John McNair
    1. File
      maven-plugin-merge/.classpath 0.7 kB
    2. File
      maven-plugin-merge/.../.classpath 0.6 kB
    3. Text File
      maven-plugin-merge/.../expected-configuration.txt 0.2 kB
    4. Java Source File
      maven-plugin-merge/.../MergeConfigurationTest.java 1 kB
    5. XML File
      maven-plugin-merge/.../pom.xml 1 kB
    6. File
      maven-plugin-merge/.../.project 0.5 kB
    7. File
      maven-plugin-merge/.../org.maven.ide.eclipse.prefs 0.2 kB
    8. File
      maven-plugin-merge/.../org.eclipse.jdt.core.prefs 0.2 kB
    9. XML File
      maven-plugin-merge/pom.xml 2 kB
    10. File
      maven-plugin-merge/.../.classpath 0.4 kB
    11. Java Source File
      maven-plugin-merge/.../FailMojo.java 1 kB
    12. Java Source File
      maven-plugin-merge/.../Element.java 0.3 kB
    13. XML File
      maven-plugin-merge/.../pom.xml 0.8 kB
    14. File
      maven-plugin-merge/.../.project 0.5 kB
    15. File
      maven-plugin-merge/.../org.maven.ide.eclipse.prefs 0.2 kB
    16. File
      maven-plugin-merge/.../org.eclipse.jdt.core.prefs 0.2 kB
    17. File
      maven-plugin-merge/.project 0.5 kB
    18. File
      maven-plugin-merge/.../org.maven.ide.eclipse.prefs 0.2 kB
    19. File
      maven-plugin-merge/.../org.eclipse.jdt.core.prefs 0.2 kB
    Download Zip
    Show
    Zip Archive
    maven-plugin-merge.zip
    05/Feb/09 11:06 AM
    13 kB
    John McNair

Issue Links

depends upon

Bug - A problem which impairs or prevents the functions of the product. PLXUTILS-129 Xpp3Dom.merge() produces wrong result upon merging two equal input DOMs

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.
is duplicated by

Bug - A problem which impairs or prevents the functions of the product. MNG-4819 Inheritance Error in Object List Configuration for Custom Plugin

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.
relates to

Bug - A problem which impairs or prevents the functions of the product. MNG-4023 Profiles from parent POM are injected multiple times if parent is part of reactor build

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Benjamin Bentmann added a comment - 14/Feb/09 5:17 AM

I could only reproduce the issue when doing a reactor build of both the parent and the child where the profile of the parent was erroneously applied multiple times, triggering the problem with Xpp3Dom merging.

The problem with multiple profile injection has been fixed as per MNG-4023 but there are other scenarios where the Xpp3Dom merging can crop in so this needs some more work to fix.

Show
Benjamin Bentmann added a comment - 14/Feb/09 5:17 AM I could only reproduce the issue when doing a reactor build of both the parent and the child where the profile of the parent was erroneously applied multiple times, triggering the problem with Xpp3Dom merging. The problem with multiple profile injection has been fixed as per MNG-4023 but there are other scenarios where the Xpp3Dom merging can crop in so this needs some more work to fix.
Hide
Permalink
Benjamin Bentmann added a comment - 06/Apr/10 4:10 PM

Fixed in r931329.

Show
Benjamin Bentmann added a comment - 06/Apr/10 4:10 PM Fixed in r931329.

People

  • Assignee:
    Benjamin Bentmann
    Reporter:
    John McNair
Vote (0)
Watch (1)

Dates

  • Created:
    05/Feb/09 11:06 AM
    Updated:
    17/Sep/10 2:46 PM
    Resolved:
    06/Apr/10 4:10 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.