-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Refactor WrapperProperties template to remove caching and simplify implementation #2436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor WrapperProperties template to remove caching and simplify implementation #2436
Conversation
…plementation This commit refactors the WrapperProperties template used for Maven model properties: TEMPLATE CHANGES (src/mdo/java/WrapperProperties.java): - Removed caching mechanism (orderedProps field and ensureInitialized() method) - Simplified read operations to directly delegate to getter.get() - Introduced writeOperation() pattern for all write operations that: * Creates a fresh OrderedProperties from current state * Performs the operation on the copy * Only calls setter if changes were made - All write operations now use synchronized writeOperation() wrapper - Maintains insertion order through OrderedProperties inner class - Supports multiple wrapper instances sharing the same backend storage The new approach eliminates cache invalidation complexity while ensuring: - Thread safety through synchronized write operations - Insertion order preservation - Immediate visibility of changes across wrapper instances - Proper delegation to underlying storage SIDE EFFECTS: - Consolidated redundant test classes into single PropertiesTest - Removed PropertiesOrderTest and WrapperPropertiesOrderTest (functionality covered by PropertiesTest) - Cleaned up duplicate test methods in PropertiesTest This refactoring simplifies the WrapperProperties implementation while maintaining all required functionality for Maven model property management.
a345aea
to
81bc67c
Compare
src/mdo/java/WrapperProperties.java
Outdated
props.storeToXML(os, comment, encoding); | ||
} | ||
|
||
|
||
private Object writeReplace() throws java.io.ObjectStreamException { | ||
Properties props = new Properties(); | ||
props.putAll(getter.get()); | ||
OrderedProperties props = new OrderedProperties(getter.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setter.accept(orderedProps); | ||
writeOperation(properties -> { | ||
runner.perform(properties); | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null; | |
return null; |
format seems broken as offset.
runner.perform(properties); | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runner.perform(properties); | |
return null; | |
runner.perform(properties); | |
return null; |
format seems broken as offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use auto formatting, so either it fails or we need to accept the output. If the CI test pass, we cannot change the formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks.
@Nested | ||
class OrderPreservationTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nested | |
class OrderPreservationTests { |
why nested if no rivals?
i like this, but only if its really in use. ATM it seems not.
FYI: see the nested feature again. @elharo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overhead for no obvious reason, seems to be the thing here all around.
assertEquals("putall.value1", wrapper.getProperty("putall.key1")); | ||
assertEquals("putall.value2", wrapper.getProperty("putall.key2")); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} |
This commit refactors the WrapperProperties template used for Maven model properties:
TEMPLATE CHANGES (src/mdo/java/WrapperProperties.java):
The new approach eliminates cache invalidation complexity while ensuring:
SIDE EFFECTS:
This refactoring simplifies the WrapperProperties implementation while maintaining
all required functionality for Maven model property management.