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

refactror: Move osgi from flow #2

Merged
merged 2 commits into from
Nov 24, 2020
Merged

refactror: Move osgi from flow #2

merged 2 commits into from
Nov 24, 2020

Conversation

denis-anisimov
Copy link

@caalador
Copy link
Contributor

Some hamcrest dependency is missing failing the validation

@denis-anisimov
Copy link
Author

Some hamcrest dependency is missing failing the validation

Indeed.
Harmcrest has been added to the master branch already before I closed it.
I think I have to rebase the branch...
Thanks for the note.

@denis-anisimov
Copy link
Author

Well, this PR needs Flow SNAPSHOT anyway.

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

Choose a reason for hiding this comment

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

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

((ClassLoaderAwareServletContainerInitializer) initializer)
.process(filterClasses(handleTypes.orElse(null)), context);
} catch (ServletException e) {
throw new RuntimeException(

Choose a reason for hiding this comment

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

MAJOR Define and throw a dedicated exception instead of using a generic one. rule


Collection<Class<?>> bundleClasses = new ArrayList<>();

for (String clazz : classes) {

Choose a reason for hiding this comment

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

MAJOR Reduce the total number of break and continue statements in this loop to use at most one. rule

}
}

public static class ResourceService {

Choose a reason for hiding this comment

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

MINOR Remove this empty class, write its code or make it an "interface". rule

HttpSessionListener, ServletContextListener {

@Reference
private ServletContainerInitializerClasses initializerClasses;

Choose a reason for hiding this comment

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

CRITICAL Make "initializerClasses" transient or serializable. rule


String contextName = generateUniqueContextName(contextPath);

Dictionary<String, String> contextProps = new Hashtable<String, String>();

Choose a reason for hiding this comment

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

MAJOR Replace the synchronized class "Hashtable" by an unsynchronized one such as "HashMap". rule
MINOR Replace the type specification in this constructor call with the diamond operator ("<>"). rule


private static final VaadinServletMarker MARKER_INSTANCE = new VaadinServletMarker();

private static final class VaadinServletMarker {

Choose a reason for hiding this comment

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

MINOR Remove this empty class, write its code or make it an "interface". rule

}

private void registerPushResources(String contextName) {
Dictionary<String, String> pushProps = new Hashtable<String, String>();

Choose a reason for hiding this comment

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

MAJOR Replace the synchronized class "Hashtable" by an unsynchronized one such as "HashMap". rule
MINOR Replace the type specification in this constructor call with the diamond operator ("<>"). rule

}

private void registerClientResources(String contextName) {
Dictionary<String, String> clientProps = new Hashtable<String, String>();

Choose a reason for hiding this comment

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

MAJOR Replace the synchronized class "Hashtable" by an unsynchronized one such as "HashMap". rule
MINOR Replace the type specification in this constructor call with the diamond operator ("<>"). rule

}
}
return contextNames;
} catch (InvalidSyntaxException exception) {

Choose a reason for hiding this comment

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

MAJOR Either log or rethrow this exception. rule


VaadinServletContext context = new VaadinServletContext(servletContext);
// ensure the context is set into the context
context.getAttribute(Lookup.class, () -> new OsgiLookupImpl());

Choose a reason for hiding this comment

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

MINOR Replace this lambda with a method reference. rule

@vaadin-bot
Copy link

SonarQube analysis reported 16 issues

  • CRITICAL 2 critical
  • MAJOR 8 major
  • MINOR 6 minor

Watch the comments in this conversation to review them.

1 extra issue

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. CRITICAL OSGiInstantiatorFactory.java#L37: Make "lookup" transient or serializable. rule

Copy link
Contributor

@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.

Just one question - what is the rule for when the (public) classes should have the Osgi.. prefix in the names ? Is it when it is an osgi specific version of something that is already in flow-server or ? Just wondering what is the practice we have so we can keep it consistent in the future.

@denis-anisimov
Copy link
Author

denis-anisimov commented Nov 24, 2020

Just one question - what is the rule for when the (public) classes should have the Osgi.. prefix in the names ? Is it when it is an osgi specific version of something that is already in flow-server or ? Just wondering what is the practice we have so we can keep it consistent in the future.

No any rule.
Just some names. Couldn't figure out anything more meaningfull.
All classes are implementation detail: they should have been private and the name in that case almost doesn't matter.
They are not private just because of framework limitation with DS.
If you five me a list of names to replace I will just copy paste.
I don't really care which names they have.

@pleku
Copy link
Contributor

pleku commented Nov 24, 2020

If you five me a list of names to replace I will just copy paste.
I don't really care which names they have.

Well, since then since everything is in an osgi package and inside the osgi artifact and repository, there probably would not be any need to use the prefix. But like you pointed out, not visible to users so there is no concerns regarding API design, it is just about how we want to do it. I don't have any opinion either on this, just wondered if there was some practice. Just let it be

@denis-anisimov
Copy link
Author

If you five me a list of names to replace I will just copy paste.
I don't really care which names they have.

Well, since then since everything is in an osgi package and inside the osgi artifact and repository, there probably would not be any need to use the prefix. But like you pointed out, not visible to users so there is no concerns regarding API design, it is just about how we want to do it. I don't have any opinion either on this, just wondered if there was some practice. Just let it be

OK.

@denis-anisimov denis-anisimov merged commit c785478 into master Nov 24, 2020
@denis-anisimov denis-anisimov deleted the move-osgi branch November 24, 2020 10:33
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.

OSGi: get rid of fake OSGiServletContext (and may be OSGiAccess).
4 participants