You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Matt Pavlovich (JIRA)" <ji...@apache.org> on 2017/03/09 18:03:38 UTC
[jira] [Updated] (OPENJPA-2690) NPE in OracleDictionary when
empty_lob_Method is not able to be specified
[ https://issues.apache.org/jira/browse/OPENJPA-2690?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matt Pavlovich updated OPENJPA-2690:
------------------------------------
Description:
When openjpa is running in an OSGi environment and all packages not being imported properly may result in the oracleClob_empty_lob_Method being set to null, a NPE will occur when trying to persist an entity with a NULL CLOB column.
getEmptyClob() (and probably getEmtpyBlob as well) should detect for oracleClob_empty_lob_Method being set to NULL before attempting to invoke the method, or just return the EMPTY_CLOB constant.
{noformat}
private Clob getEmptyClob()
throws SQLException {
if (EMPTY_CLOB != null)
return EMPTY_CLOB;
try {
return EMPTY_CLOB = (Clob) oracleClob_empty_lob_Method.invoke(null, new Object[0]);
} catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
{noformat}
Reference:
During constructor of OracleDictionry.. this may return null:
{noformat}
private Method getMethodByReflection(String className, String methodName, Class<?>... paramTypes) {
try {
return Class.forName(className,true,
AccessController.doPrivileged(J2DoPrivHelper
.getContextClassLoaderAction())).
getMethod(methodName, paramTypes);
}
catch (Exception e) {
// all fine
}
return null;
}
{noformat}
was:
When openjpa is running in an OSGi environment and some packages may result in the oracleClob_empty_lob_Method being set to null, a NPE will occur when trying to persist an entity with a NULL CLOB column.
getEmptyClob() (and probably getEmtpyBlob as well) should detect for oracleClob_empty_lob_Method being set to NULL before attempting to invoke the method, or just return the EMPTY_CLOB constant.
{noformat}
private Clob getEmptyClob()
throws SQLException {
if (EMPTY_CLOB != null)
return EMPTY_CLOB;
try {
return EMPTY_CLOB = (Clob) oracleClob_empty_lob_Method.invoke(null, new Object[0]);
} catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
{noformat}
Reference:
During constructor of OracleDictionry.. this may return null:
{noformat}
private Method getMethodByReflection(String className, String methodName, Class<?>... paramTypes) {
try {
return Class.forName(className,true,
AccessController.doPrivileged(J2DoPrivHelper
.getContextClassLoaderAction())).
getMethod(methodName, paramTypes);
}
catch (Exception e) {
// all fine
}
return null;
}
{noformat}
> NPE in OracleDictionary when empty_lob_Method is not able to be specified
> -------------------------------------------------------------------------
>
> Key: OPENJPA-2690
> URL: https://issues.apache.org/jira/browse/OPENJPA-2690
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 2.4.2
> Reporter: Matt Pavlovich
>
> When openjpa is running in an OSGi environment and all packages not being imported properly may result in the oracleClob_empty_lob_Method being set to null, a NPE will occur when trying to persist an entity with a NULL CLOB column.
> getEmptyClob() (and probably getEmtpyBlob as well) should detect for oracleClob_empty_lob_Method being set to NULL before attempting to invoke the method, or just return the EMPTY_CLOB constant.
> {noformat}
> private Clob getEmptyClob()
> throws SQLException {
> if (EMPTY_CLOB != null)
> return EMPTY_CLOB;
> try {
> return EMPTY_CLOB = (Clob) oracleClob_empty_lob_Method.invoke(null, new Object[0]);
> } catch (Exception e) {
> throw new SQLException(e.getMessage());
> }
> }
> {noformat}
> Reference:
> During constructor of OracleDictionry.. this may return null:
> {noformat}
> private Method getMethodByReflection(String className, String methodName, Class<?>... paramTypes) {
> try {
> return Class.forName(className,true,
> AccessController.doPrivileged(J2DoPrivHelper
> .getContextClassLoaderAction())).
> getMethod(methodName, paramTypes);
> }
> catch (Exception e) {
> // all fine
> }
> return null;
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)