You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/10/03 14:55:50 UTC
DO NOT REPLY [Bug 23591] New: -
NPE in setOutputProperties with null arg
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23591>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23591
NPE in setOutputProperties with null arg
Summary: NPE in setOutputProperties with null arg
Product: XalanJ2
Version: 2.5
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xalan.transformer
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: Mike.French@screwfix.com
Version 2.5.1
If the properties argument to setOutputProperties is null,
it should reset the values to the system defaults,
but it gives an NPE at org.apache.xalan.transformer.TransformerImpl:941
Existing code:
public void setOutputProperties(Properties oformat)
throws IllegalArgumentException
{
synchronized (m_reentryGuard)
{
if (null != oformat)
{
// See if an *explicit* method was set.
String method = (String) oformat.get(OutputKeys.METHOD);
if (null != method)
m_outputFormat = new OutputProperties(method);
else if(m_outputFormat==null)
m_outputFormat = new OutputProperties();
}
if (null != oformat)
{
m_outputFormat.copyFrom(oformat);
}
// copyFrom does not set properties that have been already set, so
// this must be called after, which is a bit in the reverse from
// what one might think.
NPE m_outputFormat.copyFrom(m_stylesheetRoot.getOutputProperties());
}
}
In the case where oformat arg is null
and m_outputFormat is initially null
then m_outputFormat does not get initialized.
As a quick fix I moved the m_outputFormat initialization
outside the null test. I haven't verified whether this
produces correct behavior, but it doesn't NPE any more :)
public void setOutputProperties(Properties oformat)
throws IllegalArgumentException
{
synchronized (m_reentryGuard)
{
if (null != oformat)
{
// See if an *explicit* method was set.
String method = (String) oformat.get(OutputKeys.METHOD);
if (null != method)
m_outputFormat = new OutputProperties(method);
>> }
>>
>> if(m_outputFormat==null)
>> m_outputFormat = new OutputProperties();
if (null != oformat)
{
m_outputFormat.copyFrom(oformat);
}
// copyFrom does not set properties that have been already set, so
// this must be called after, which is a bit in the reverse from
// what one might think.
m_outputFormat.copyFrom(m_stylesheetRoot.getOutputProperties());
}
}
Mike