nacx commented on this pull request.


> @@ -344,7 +349,17 @@ private void discoverCommands(CommandProcessorImpl 
> commandProcessor, ClassLoader
                         @Override
                         public Action createNewAction() {
                             try {
-                                return ((Class<? extends Action>) 
actionClass).newInstance();
+                               Action action = ((Class< ? extends Action>) 
actionClass).newInstance();
+                               if (action instanceof ComputeCommandBase) {
+                                   ShellTableFactory shellTableFactory = 
((ComputeCommandBase) action).getShellTableFactory();
+                                   if (shellTableFactory instanceof 
BasicShellTableFactory) {
+                                       BasicShellTableFactory factory = 
(BasicShellTableFactory) shellTableFactory;
+                                       if (factory.getScriptEngineManager() == 
null) {
+                                           factory.setScriptEngineManager(new 
ScriptEngineManager());

>new ScriptEngineManager() - do we need a new instance here each time, or can 
>an instance be shared?

That was my first approach. I initialised as a final class variable, but there 
were side issues. It also makes sense that each command has its own engine.

Regarding the others, sure. I'll open a PR to move that to a method and 
properly describe the workaround (I think we don't need to cut a RC4 for this, 
right? :)). The null guard conditional is just an extra safety. That will 
always be null, but, it is an extra check that could save us some debugging if 
we change things in the future (unlikely, but it's a cheap check).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-cli/pull/35

Reply via email to