Skip to content
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

Improved the feature installation logic #256

Merged
merged 1 commit into from Dec 12, 2017
Merged

Conversation

@kaikreuzer
Copy link
Member

@kaikreuzer kaikreuzer commented Dec 11, 2017

  • wait for config update when online status has changed
  • removed static methods and logger
  • proper handling of "minimal" feature
  • introduced a sync job that checks if everything is installed as expected (which serves as a retry mechanism in case of failed downloads)

fixes openhab/openhab-distro#602

Signed-off-by: Kai Kreuzer kai@openhab.org

- wait for config update when online status has changed
- removed static methods and logger
- proper handling of "minimal" feature
- introduced a sync job that checks if everything is installed as expected (which serves as a retry mechanism in case of failed downloads)

fixes openhab/openhab-distro#602

Signed-off-by: Kai Kreuzer <kai@openhab.org>
Copy link
Member

@martinvw martinvw left a comment

Thanks for your contribution ;-) I have added some minor comments.

Btw what is the main change which actually fixes openhab/openhab-distro#602

@@ -106,14 +116,34 @@ protected void activate(final Map<String, Object> config) {
setOnlineRepoUrl();
setLegacyRepoUrl();
modified(config);
scheduler = Executors.newSingleThreadScheduledExecutor();
Copy link
Member

@martinvw martinvw Dec 12, 2017

I would maybe initialize where I declare it, for me that feels safer.

Copy link
Member Author

@kaikreuzer kaikreuzer Dec 12, 2017

No, because it needs to be (re-)initialized upon activation and shut down on deactivation.

logger.debug("Running scheduled sync job");
try {
Dictionary<String, Object> cfg = configurationAdmin.getConfiguration(ADDONS_PID).getProperties();
Iterator<String> keysIter = Iterators.forEnumeration(cfg.keys());
Copy link
Member

@martinvw martinvw Dec 12, 2017

:-( unfortunately this is the best way which I can also find..

@@ -302,11 +332,13 @@ private boolean setOnlineStatus(boolean status) {
if (!repoCfg.contains(online_repo_url)) {
repoCfg.add(online_repo_url);
changed = true;
logger.debug("Added repo '{}' to feature repo list.", online_repo_url);
Copy link
Member

@martinvw martinvw Dec 12, 2017

Not new, but

online_repo_url => does not follow naming conventions.

Copy link
Member Author

@kaikreuzer kaikreuzer Dec 12, 2017

right, not new.

if (installFeature(featuresService, name)) {
configChanged = true;
String fullName = PREFIX + PREFIX_PACKAGE + ((String) packageName).trim();
if (currentPackage.equals(MINIMAL_PACKAGE)) {
Copy link
Member

@martinvw martinvw Dec 12, 2017

Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false. source: PMD

Copy link
Member Author

@kaikreuzer kaikreuzer Dec 12, 2017

We are inside an "instanceof String" check, so we can be sure it is not null.

Copy link
Member

@martinvw martinvw Dec 12, 2017

But is still a good habit 😜

} else {
if (installFeature(featuresService, fullName)) {
configChanged = true;
}
Copy link
Member

@martinvw martinvw Dec 12, 2017

Should we log anything here or is that already done inside installFeature in the case of failure.

Copy link
Member Author

@kaikreuzer kaikreuzer Dec 12, 2017

that's done in installFeature.

@kaikreuzer
Copy link
Member Author

@kaikreuzer kaikreuzer commented Dec 12, 2017

@martinvw martinvw merged commit 50c01f2 into openhab:master Dec 12, 2017
1 check passed
@kaikreuzer kaikreuzer deleted the featint branch Dec 12, 2017
@kaikreuzer kaikreuzer added this to the 2.2 milestone Dec 15, 2017
@kaikreuzer kaikreuzer removed this from the 2.2 milestone Dec 15, 2017
@kaikreuzer kaikreuzer added this to the 2.2 milestone Dec 15, 2017
@openhab-bot
Copy link
Collaborator

@openhab-bot openhab-bot commented Nov 6, 2018

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/why-is-openhab-server-calling-openhab-jfrog-io/45372/50

Rosi2143 pushed a commit to Rosi2143/openhab-core that referenced this issue Dec 26, 2020
Signed-off-by: Ben Clark <ben@benjyc.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants