You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2018/09/06 21:35:00 UTC

[jira] [Commented] (CALCITE-2541) Calcite core is vulnerable to exposing through OSGI

    [ https://issues.apache.org/jira/browse/CALCITE-2541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16606416#comment-16606416 ] 

Julian Hyde commented on CALCITE-2541:
--------------------------------------

Sounds good. Looking forward to the PR.

Any idea how you would test this?

> Calcite core is vulnerable to exposing through OSGI
> ---------------------------------------------------
>
>                 Key: CALCITE-2541
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2541
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Piotr Bojko
>            Assignee: Julian Hyde
>            Priority: Major
>
> When exposing connection created by Calcite through OSGI to another bundle - class not found it thrown everywhere from code as following:
> {code:java}
>  ICompilerFactory compilerFactory;
>     try {
>       compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
>     } catch (Exception e) {
>       throw new IllegalStateException(
>           "Unable to instantiate java compiler", e);
>     }
> {code}
> This is because org.codehaus.commons.compiler.CompilerFactoryFactory uses classloader from current thread, where in OSGI exposed to different bundles thread classloader may not reach valid janino or org.codehaus.commons.compiler, appropriate for Calcite version (or at all).
> I would suggest changing the mentioned code with additional fallback:
>   
> {code:java}
>  ICompilerFactory compilerFactory;
>     try {
>       compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
>     } catch (ClassNotFoundException e) {
>       compilerFactory = new org.codehaus.janino.CompilerFactory();
>     } catch (Exception e) {
>       throw new IllegalStateException(
>           "Unable to instantiate java compiler", e);
>     }
> {code}
> Change in:
> * EnumerableInterpretable.getBindable(ClassDeclaration, String, int)
> * JaninoRexCompiler.getScalar(ClassDeclaration, String)
> * JaninoRelMetadataProvider.compile(String, String, MetadataDef<M>, List<Object>)
> This should clear the way between calcite and an osgi world :)
> When accepted I will make a pull request.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)