Our project (WebLogic Deploy Tooling) has code that is working properly on Jython 2.7.1. Our upcoming release has moved to Jython 2.7.3 and the code that was previously working is now failing. Here is a simplified snippet of what we are doing (with some debugging lines added):
import java.lang.Throwable as Throwable
import oracle.weblogic.deploy.create.CreateException as CreateException
...
def create_create_exception(key, *args, **kwargs):
"""
Create a CreateException from a message id, list of message parameters and Throwable error.
:param key: key to the message in resource bundler or the message itself
:param args: list of parameters for the parameters or empty if none needed for the message
:param kwargs: contains Throwable or instance if present
:return: CreateException encapsulating the exception information
"""
arg_list, error = _return_exception_params(*args, **kwargs)
print('arg_list (%s) = %s' % (type(arg_list), arg_list))
arg_len = len(arg_list)
if error is not None:
if isinstance(error, Throwable) is False:
print('error is not Throwable')
error = convert_error_to_exception()
print('converted error = %s' % error)
if arg_len > 0:
print('Calling CreateException(key, error, arg_list) with error that is an instance of Throwable (%s)' % isinstance(error, Throwable))
ex = CreateException(key, error, arg_list)
else:
print('Calling CreateException(key, error)')
ex = CreateException(key, error)
else:
if arg_len > 0:
print('Calling CreateException(key, arg_list)')
ex = CreateException(key, arg_list)
else:
print('Calling CreateException(key)')
ex = CreateException(key)
return ex
The CreateException class has 5 overloaded constructor methods including the two relevant to this situation:
public class CreateException extends BundleAwareException {
private static final long serialVersionUID = 1L;
public CreateException() {
// default constructor
}
public CreateException(String messageID) {
super(messageID);
}
public CreateException(String messageID, Object... params) {
super(messageID, params);
System.out.println("Inside CreateException(String messageID, Object... params) constructor");
if (params[0] instanceof Throwable) {
System.out.println("Inside wrong CreateException() constructor");
} else {
System.out.println("Second arg is not a Throwable: " + params[0].getClass().getName());
}
}
public CreateException(String messageID, Throwable cause) {
super(messageID, cause);
}
public CreateException(String messageID, Throwable cause, Object... params) {
super(messageID, cause, params);
System.out.println("Inside CreateException(String messageID, Throwable cause, Object... params) constructor");
}
public CreateException(Throwable cause) {
super(cause);
}
@Override
public String getBundleName() {
return ExceptionHelper.getResourceBundleName();
}
}
When running the code with Jython 2.7.1, the output from the debugging code look like this:
arg_list (<type 'list'>) = ['Password', u'/Security/mydomain/User/weblogic', '<masked>', u'60455: Invalid password.\n60455: The password must be at least 8 alphanumeric characters with at least one number or special character.\n60455: Correct the password.']
Calling CreateException(key, error, arg_list) with error that is an instance of Throwable (True)
Inside CreateException(String messageID, Throwable cause, Object... params) constructor
When switching to 2.7.3, the output changes to reflect the problem:
arg_list (<type 'list'>) = ['Password', u'/Security/mydomain/User/weblogic', '<masked>', u'60455: Invalid password.\n60455: The password must be at least 8 alphaumeric characters with at least one number or special character.\n60455: Correct the password.']
Calling CreateException(key, error, arg_list) with error that is an instance of Throwable (True)
Inside CreateException(String messageID, Object... params) constructor
Inside wrong CreateException() constructor
Our project (WebLogic Deploy Tooling) has code that is working properly on Jython 2.7.1. Our upcoming release has moved to Jython 2.7.3 and the code that was previously working is now failing. Here is a simplified snippet of what we are doing (with some debugging lines added):
The CreateException class has 5 overloaded constructor methods including the two relevant to this situation:
When running the code with Jython 2.7.1, the output from the debugging code look like this:
When switching to 2.7.3, the output changes to reflect the problem: