-
Bug
-
Resolution: External
-
P4
-
None
-
17
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Problem for all systems.
A DESCRIPTION OF THE PROBLEM :
The opening lines of `DocumentBuilderFactoryImpl#getAttribute` are:
```
public Object getAttribute(String name)
throws IllegalArgumentException
{
//check if the property is managed by security manager
String pName;
if ((pName = fSecurityManager.find(name)) != null) {
return attributes.get(pName);
} else if ((pName = fSecurityPropertyMgr.find(name)) != null) {
return attributes.get(pName);
}
// See if it's in the attributes Map
if (attributes != null) {
Object val = attributes.get(name);
if (val != null) {
return val;
}
}
```
The security check appears to have been added in 2021. It attempts to check the `attributes` attribute *before checking to see if `attributes` is null`.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Bug discovered when using Eclipse & XText.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should not be a null pointer exception
ACTUAL -
NullPointerException occurs because `attributes` is null.
CUSTOMER SUBMITTED WORKAROUND :
The fix is to change the opening code to this:
```
public Object getAttribute(String name)
throws IllegalArgumentException
{
if (attributes != null) {
//check if the property is managed by security manager
String pName;
if ((pName = fSecurityManager.find(name)) != null) {
return attributes.get(pName);
} else if ((pName = fSecurityPropertyMgr.find(name)) != null) {
return attributes.get(pName);
}
// See if it's in the attributes Map
Object val = attributes.get(name);
if (val != null) {
return val;
}
}
```
FREQUENCY : occasionally
Problem for all systems.
A DESCRIPTION OF THE PROBLEM :
The opening lines of `DocumentBuilderFactoryImpl#getAttribute` are:
```
public Object getAttribute(String name)
throws IllegalArgumentException
{
//check if the property is managed by security manager
String pName;
if ((pName = fSecurityManager.find(name)) != null) {
return attributes.get(pName);
} else if ((pName = fSecurityPropertyMgr.find(name)) != null) {
return attributes.get(pName);
}
// See if it's in the attributes Map
if (attributes != null) {
Object val = attributes.get(name);
if (val != null) {
return val;
}
}
```
The security check appears to have been added in 2021. It attempts to check the `attributes` attribute *before checking to see if `attributes` is null`.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Bug discovered when using Eclipse & XText.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should not be a null pointer exception
ACTUAL -
NullPointerException occurs because `attributes` is null.
CUSTOMER SUBMITTED WORKAROUND :
The fix is to change the opening code to this:
```
public Object getAttribute(String name)
throws IllegalArgumentException
{
if (attributes != null) {
//check if the property is managed by security manager
String pName;
if ((pName = fSecurityManager.find(name)) != null) {
return attributes.get(pName);
} else if ((pName = fSecurityPropertyMgr.find(name)) != null) {
return attributes.get(pName);
}
// See if it's in the attributes Map
Object val = attributes.get(name);
if (val != null) {
return val;
}
}
```
FREQUENCY : occasionally