Issue2097

classification
Title: os.system behaves differently in Jython 2.5.2 than in 2.2.1
Type: behaviour Severity: critical
Components: Library Versions: Jython 2.5
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: eeiddne, eolikil, zyasoft
Priority: Keywords:

Created on 2013-10-07.16:11:52 by eeiddne, last changed 2014-06-18.17:45:03 by zyasoft.

Messages
msg8145 (view) Author: Donal Duane (eeiddne) Date: 2013-10-07.16:11:51
Hi,

Not sure if this is a bug yet, so apologies if it is not.
We have upgraded from Jython 2.2.1, to 2.5.2, and we are seeing issues with maaPlugin.

Has this changed between these releases?

The following is a sample script which is failing throwing NullPointer Exception for Jython 2.5.2, but not for 2.2.1:

 

class NULLpointer:

import os
import re
import string
import time
from com.ericsson.nms.umts.cnos.config.activitysupport.maaPlugin import MaaPlugin
from java.lang import *

maaPlugin = MaaPlugin(node)
maaPlugin.reportProgress(10)
maaPlugin.start()
maaPlugin.putInLog("CACLP from shell /tmp/caclp.sh "+node)
res=os.system("/tmp/caclp.sh "+node)
maaPlugin.end()
maaPlugin = MaaPlugin(node)
maaPlugin.start()
maaPlugin.reportProgress(90)
maaPlugin.end()

 


Regards,
Dónal
msg8146 (view) Author: Donal Duane (eeiddne) Date: 2013-10-07.16:16:12
From the code snippet, the following returns an exception: 

"os.system("/tmp/caclp.sh "+node)" of this script.

Has this code changed for Jython 2.5.2?
Is there a way around this?

Regards,
Dónal
msg8148 (view) Author: Donal Duane (eeiddne) Date: 2013-10-08.15:16:24
Further addition:

This issue seems to revolve around the way os.system handles return codes in Jython 2.5.2 vs older versions (somewhere between 2.2.0 & 2.5.2 - we have nto tried the intermediary versions)

os.system("/tmp/caclp.sh "+node)

1st when we run our Java application, it creates a main() thread which internally creates JobManager() thread and which internally creates a ActivityThread() and in that activityThread, we execute the caclp.sh script.


- It seems os.system is not happy with the return code from the sample scrit (which contains some unix commands) so when os.system() call has been executed, activityThread() name has been changed to mainThread()

and if we call maaPlugin(node) command, it is not getting the activityID, because it is out of that thread and it has gone to mainThread()
hence we get a NullPointerException...
msg8152 (view) Author: oliver killian (eolikil) Date: 2013-10-15.14:59:02
2013-09-19 13:40:33,496) DEBUG [MainThread] (PluginImpl.java:863) - com.ericsson.nms.umts.cnos.config.activitysupport.maaPlugin.MaaPlugin@27a30c
(2013-09-19 13:40:33,499) ERROR [MainThread] (PluginImpl.java:1160) - Couldn't find key in this Thread name!
(2013-09-19 13:40:33,504) ERROR [MainThread] (PluginImpl.java:138) - Failed to get Job ID null
java.lang.NullPointerException
                at com.ericsson.nms.umts.cnos.config.activitysupport.taskserver.plugin.PluginImpl.<init>(PluginImpl.java:135)
                at com.ericsson.nms.umts.cnos.config.activitysupport.maaPlugin.MaaPlugin.<init>(MaaPlugin.java:51)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:210)
                at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:179)
                at org.python.core.PyObject.__call__(PyObject.java:345)
                at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
                at org.python.core.PyMethod.__call__(PyMethod.java:211)
                at org.python.core.PyMethod.__call__(PyMethod.java:206)
                at org.python.core.Deriveds.dispatch__init__(Deriveds.java:19)
                at org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java:1057)
                at org.python.core.PyType.type___call__(PyType.java:1565)
                at org.python.core.PyType.__call__(PyType.java:1548)
                at org.python.core.PyObject.__call__(PyObject.java:387)
                at org.python.core.PyObject.__call__(PyObject.java:391)
                at org.python.pycode._pyx12.NULLpointer$1(<string>:17)
                at org.python.pycode._pyx12.call_function(<string>)
                at org.python.core.PyTableCode.call(PyTableCode.java:165)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
                at org.python.core.Py.makeClass(Py.java:1598)
                at org.python.core.Py.makeClass(Py.java:1592)
                at org.python.pycode._pyx12.f$0(<string>:1)
                at org.python.pycode._pyx12.call_function(<string>)
                at org.python.core.PyTableCode.call(PyTableCode.java:165)
                at org.python.core.PyCode.call(PyCode.java:18)
                at org.python.core.Py.runCode(Py.java:1261)
                at org.python.core.Py.exec(Py.java:1305)
                at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
msg8153 (view) Author: oliver killian (eolikil) Date: 2013-10-15.20:35:05
could this be a subprocess issue ?  .  I see references to replacing os.system from 2.4 
http://www.jython.org/docs/library/subprocess.html
.
msg8158 (view) Author: oliver killian (eolikil) Date: 2013-10-17.13:40:36
still strugging with this,  have implemented a number of changes,  specifically around calls to os.system.   still hitting a null pointer.
msg8159 (view) Author: oliver killian (eolikil) Date: 2013-10-17.13:52:30
looks like same issue,  has other support cases ,  1868 adn 2098. 
any possible workarounds here,  that do not involve a rollback to 2.2.1
msg8465 (view) Author: Jim Baker (zyasoft) Date: 2014-05-21.20:41:09
Can we reproduce by using a script that's not Ericsson specific?

There have been some changes since 2.2 in general around making Jython comply much more with CPython. However, we would not expect a NPE.

Most likely any fix would be against Jython 2.7. If we can reproduce, this should be part of a beta 4 for 2.7.
msg8475 (view) Author: Jim Baker (zyasoft) Date: 2014-05-21.21:20:16
Duplicated in #2098, which has some potentially useful content re the Ericsson bug
msg8669 (view) Author: Jim Baker (zyasoft) Date: 2014-06-18.17:45:03
No response from OP so closing out as invalid
History
Date User Action Args
2014-06-18 17:45:03zyasoftsetstatus: open -> closed
resolution: invalid
messages: + msg8669
2014-05-21 21:20:16zyasoftsetmessages: + msg8475
2014-05-21 20:41:09zyasoftsetnosy: + zyasoft
messages: + msg8465
2013-10-17 13:52:31eolikilsetmessages: + msg8159
components: + Library, - Core
2013-10-17 13:40:37eolikilsetmessages: + msg8158
components: + Core, - Any
2013-10-15 20:35:05eolikilsetmessages: + msg8153
2013-10-15 14:59:03eolikilsettype: crash -> behaviour
messages: + msg8152
components: + Any, - Core
nosy: + eolikil
2013-10-08 15:16:25eeiddnesetmessages: + msg8148
2013-10-08 14:51:21eeiddnesettitle: maaPlugin differs in Jython 2.5.2 from 2.2.1 -> os.system behaves differently in Jython 2.5.2 than in 2.2.1
2013-10-07 16:16:12eeiddnesetmessages: + msg8146
2013-10-07 16:11:52eeiddnecreate