You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (Jira)" <ji...@apache.org> on 2023/11/12 11:11: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=17785278#comment-17785278 ] 

Vladimir Sitnikov commented on CALCITE-2541:
--------------------------------------------

I believe a better way would be convincing Janino to use ServiceLoader API instead of custom resources: https://github.com/janino-compiler/janino/issues/209

> 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
>            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
(v8.20.10#820010)