-
Notifications
You must be signed in to change notification settings - Fork 2.7k
refine getPluginsAsMap #2482
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
base: master
Are you sure you want to change the base?
refine getPluginsAsMap #2482
Conversation
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.
I don't really follow the purpose of this PR. maybe someone else will.
|
||
volatile Map<String, Plugin> pluginMap; | ||
|
||
protected void cleanDelegateCache() { |
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.
why do we need this? Why not just call flushPluginMap? It's only a one-liner
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.
because it is weird to register flushPluginMap as a function in the base class.
the idea was, cleanDelegateCache be a abstract class, and the flushPluginMap is only what this specific situation in this class needs.
well, we decide to continue using modello, didn't we.....
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.
Then maybe inline flushPluginMap into this method?
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.
I'd rather avoid any breakage in the 3.x model since it's supposed to be stable.
* @see Plugin#getKey() | ||
*/ | ||
public Map<String, Plugin> getPluginsAsMap() { | ||
return getPlugins().stream().collect(Collectors.toMap(plugin -> plugin.getKey(), plugin -> plugin)); | ||
if (pluginMap == null) { | ||
synchronized (this) { |
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.
I don't see a specific problem but the thread safety here makes me nervous.
@elharo Though the bitter truth is adding the prs I opened last weekend in maven project up, has about 3% performance increasing on that test on my machine, but the maven-resolver pr I opened has 30%+ performance refnie. |
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.
Instead of building a map, lazily or not, could we instead only have a map and iterate through that instead of a list of plugins?
|
||
volatile Map<String, Plugin> pluginMap; | ||
|
||
protected void cleanDelegateCache() { |
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.
Then maybe inline flushPluginMap into this method?
Yes that is thr original thought. Though I have no idea how to make modello generate it to a map, not a list |
} | ||
|
||
/** | ||
* @return a Map of plugins field with {@code Plugins#getKey()} as key | ||
* @return a Map of plugins field with {@link Plugin#getKey()} as key |
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.
a map of plugin keys to plugins
Modello isn't very well documented or supported. If you make the plugins field a map instead of a list, it might work, but it might not. I'm not sure. There might be some way to add custom code and replace default generated code with custom code, but again I don't really know. |
|
||
volatile Map<String, Plugin> pluginMap; | ||
|
||
protected void cleanDelegateCache() { |
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.
needs Override annotation
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verify
to make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.