Piotr Bojko created CALCITE-2541:
------------------------------------
Summary: 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
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)