[MNG-8746] Preserve property insertion order in WrapperProperties by gnodet · Pull Request #2404 · apache/maven (original) (raw)

@gnodet

This commit implements order preservation for properties in the Maven compat layer's WrapperProperties class, ensuring that properties maintain their insertion order when accessed through the Properties API.

Key changes:

  1. Enhanced WrapperProperties template (src/mdo/java/WrapperProperties.java):

    • Added internal OrderedProperties class that maintains insertion order
    • Implemented caching mechanism to preserve order across read/write operations
    • Modified all read operations to use the ordered cache
    • Simplified write operations to work directly with the ordered properties
  2. OrderedProperties implementation:

    • Uses ArrayList to track key insertion order
    • Overrides put/setProperty/remove to maintain order
    • Custom KeySet and EntrySet implementations that iterate in insertion order
    • Removed unnecessary synchronized wrappers that interfered with ordering
  3. Updated model-v3.vm template:

    • Ensured LinkedHashMap is used when converting properties to v4 API
    • This preserves order when properties are synced between compat and v4 layers
  4. Added comprehensive tests:

    • PropertiesOrderTest: Tests v4 API model order preservation
    • WrapperPropertiesOrderTest: Tests compat layer order preservation
    • Covers various scenarios including modification and initial properties

The implementation ensures that properties accessed through model.getProperties() maintain their insertion order, which is important for consistent behavior and reproducible builds.

Fixes: MNG-8746

cstamas

approved these changes May 28, 2025

Pankraz76

@gnodet @Pankraz76

Co-authored-by: Pankraz76 8830888+Pankraz76@users.noreply.github.com

@gnodet @Pankraz76

Co-authored-by: Pankraz76 8830888+Pankraz76@users.noreply.github.com

@gnodet gnodet deleted the fix-MNG-8746 branch

June 4, 2025 09:10

@gnodet gnodet added the bug

Something isn't working

label

Jun 4, 2025

Pankraz76 added a commit to Pankraz76/maven that referenced this pull request

Jun 4, 2025

@gnodet @Pankraz76

…ache#2404)

This commit implements order preservation for properties in the Maven compat layer's WrapperProperties class, ensuring that properties maintain their insertion order when accessed through the Properties API.

Key changes:

  1. Enhanced WrapperProperties template (src/mdo/java/WrapperProperties.java):

    • Added internal OrderedProperties class that maintains insertion order
    • Implemented caching mechanism to preserve order across read/write operations
    • Modified all read operations to use the ordered cache
    • Simplified write operations to work directly with the ordered properties
  2. OrderedProperties implementation:

    • Uses ArrayList to track key insertion order
    • Overrides put/setProperty/remove to maintain order
    • Custom KeySet and EntrySet implementations that iterate in insertion order
    • Removed unnecessary synchronized wrappers that interfered with ordering
  3. Updated model-v3.vm template:

    • Ensured LinkedHashMap is used when converting properties to v4 API
    • This preserves order when properties are synced between compat and v4 layers
  4. Added comprehensive tests:

    • PropertiesOrderTest: Tests v4 API model order preservation
    • WrapperPropertiesOrderTest: Tests compat layer order preservation
    • Covers various scenarios including modification and initial properties

The implementation ensures that properties accessed through model.getProperties() maintain their insertion order, which is important for consistent behavior and reproducible builds.

Fixes: MNG-8746

Co-authored-by: Pankraz76 8830888+Pankraz76@users.noreply.github.com

Co-authored-by: Pankraz76 8830888+Pankraz76@users.noreply.github.com


Co-authored-by: Pankraz76 8830888+Pankraz76@users.noreply.github.com

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})