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

Add OSGi to usage statistics #4895

Merged
merged 1 commit into from
Dec 21, 2018
Merged

Add OSGi to usage statistics #4895

merged 1 commit into from
Dec 21, 2018

Conversation

pleku
Copy link
Contributor

@pleku pleku commented Dec 20, 2018

The OSGi detection seems impossible to fake from a test that doesn't
have OSGi framework on the classpath, so no test for this.


This change is Reviewable

Copy link
Contributor

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1.
Reviewable status: 3 unresolved discussions, 0 of 1 LGTMs obtained


flow-server/src/main/java/com/vaadin/flow/server/osgi/OSGiAccess.java, line 283 at r1 (raw file):

 } catch (Exception e) {

In case there is no such class there will be NoClassDefFoundError ( I think) which extends Throwable and doesn't extend Exception.

I'm not sure about this catch though: why do you catch everything ?
It seems that it's used only when inside OSGi env. So I don't see a reason to catch Exception.


flow-server/src/main/java/com/vaadin/flow/server/startup/ApplicationRouteRegistry.java, line 134 at r1 (raw file):

 UsageStatistics.markAsUsed("flow/OSGi", OSGiAccess.getOSGiVersion());

I think that semantically this is not the proper place for this.
This functionality is quite specific for routes. And it's a bit weird to have usage statistic here.

May be the statistic may be moved to the OSGiAccess inside LazyOSGiDetector which detects OSGi env presence.

Copy link
Contributor Author

@pleku pleku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 unresolved discussions, 0 of 1 LGTMs obtained


flow-server/src/main/java/com/vaadin/flow/server/osgi/OSGiAccess.java, line 283 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…
 } catch (Exception e) {

In case there is no such class there will be NoClassDefFoundError ( I think) which extends Throwable and doesn't extend Exception.

I'm not sure about this catch though: why do you catch everything ?
It seems that it's used only when inside OSGi env. So I don't see a reason to catch Exception.

I would rather have just broken usage statistics for OSGi than have broken usage statics for OSGi that also break OSGi usage.


flow-server/src/main/java/com/vaadin/flow/server/startup/ApplicationRouteRegistry.java, line 134 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…
 UsageStatistics.markAsUsed("flow/OSGi", OSGiAccess.getOSGiVersion());

I think that semantically this is not the proper place for this.
This functionality is quite specific for routes. And it's a bit weird to have usage statistic here.

May be the statistic may be moved to the OSGiAccess inside LazyOSGiDetector which detects OSGi env presence.

Done.

@@ -263,10 +265,29 @@ private ServletContext createOSGiServletContext() {
private static boolean isInOSGi() {
try {
Class.forName("org.osgi.framework.FrameworkUtil");

UsageStatistics.markAsUsed("flow/osgi", getOSGiVersion());

return true;
} catch (ClassNotFoundException exception) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL Either log or rethrow this exception. rule

try {
Bundle osgiBundle = org.osgi.framework.FrameworkUtil.getBundle(Bundle.class);
return osgiBundle.getVersion().toString();
} catch (Throwable throwable) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL Either log or rethrow this exception. rule
MAJOR Catch Exception instead of Throwable. rule

The OSGi detection seems impossible to fake from a test that doesn't
have OSGi framework on the classpath, so no test for this.
Copy link
Contributor

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r3.
Reviewable status: 3 unresolved discussions, 1 of 1 LGTMs obtained

Copy link
Contributor

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismissed @vaadin-bot from 3 discussions.
Reviewable status: :shipit: complete! all discussions resolved, 1 of 1 LGTMs obtained

@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 5 issues

  • CRITICAL 2 critical
  • MAJOR 3 major

Watch the comments in this conversation to review them.

2 extra issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. MAJOR OSGiAccess.java#L209: Define and throw a dedicated exception instead of using a generic one. rule
  2. MAJOR OSGiAccess.java#L262: Add a private constructor to hide the implicit public one. rule

@pleku pleku merged commit 4b8cd9b into master Dec 21, 2018
@pleku pleku deleted the add_osgi_usage branch December 21, 2018 09:44
pleku added a commit that referenced this pull request Dec 21, 2018
The OSGi detection seems impossible to fake from a test that doesn't
have OSGi framework on the classpath, so no test for this.
@pleku
Copy link
Contributor Author

pleku commented Dec 21, 2018

Cherry-picking to 1.2

@bogdanudrescu bogdanudrescu added this to the 1.3.0.alpha2 milestone Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants