-
Notifications
You must be signed in to change notification settings - Fork 7
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
SLING-8523 : Duplicate OSGI configs after upgrade #4
Conversation
Upgrade resulting in duplicate factory configs for cases where alais is null
@cziegeler , please review |
|
||
final String factoryPid = alias.substring(0, pos - 1); | ||
final String pid = oldId.substring(factoryPid.length() + 1); | ||
String factoryIdString = oldId.substring(0,oldId.lastIndexOf('.')+1); // keep it +1 to have last dot intact so that we always have even dots in the string |
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.
you could store lastIndexOf in an int variable and reuse it below
final String pid = oldId.substring(factoryPid.length() + 1); | ||
String factoryIdString = oldId.substring(0,oldId.lastIndexOf('.')+1); // keep it +1 to have last dot intact so that we always have even dots in the string | ||
factoryPid = oldId.substring(0,getMiddleDotSplitIndex(factoryIdString,'.')); | ||
pid = oldId.substring(oldId.lastIndexOf('.')+1,oldId.length()); |
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.
substring(int) is enough, if you only specify the start it goes until the of the string
@cziegeler , Thanks for the review, added a test case to cover the new code and incorporated your code comments. Please merge. |
Added cleanup for existing duplicate configs generated before this Patch
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.
Thanks for the updated patch, it looks good to me
|
||
return new String[] { factoryPid, pid }; | ||
} | ||
|
||
private int getMiddleDotSplitIndex(final String strId, char dot){ |
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 method is only invoked with the second param being a ".", so you only need one param and can use a constant for "." below
Upgrade resulting in duplicate factory configs for cases where alais is null