GeoAPI

NPE in org.opengis.feature.IllegalAttributeException.toString()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.2-M2, 2.2, 3.0.0
  • Fix Version/s: 2.3-M3
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

If org.opengis.feature.IllegalAttributeException is constructed with a null descriptor, such as in GeoTools org.geotools.feature.IllegalAttributeException(String), org.opengis.feature.IllegalAttributeException.toString() fails with a NullPointerException, when descriptor.getName() is called. The correct solution would be Do Not Do That Then (TM), or even get rid of the deprecated org.geotools.feature.IllegalAttributeException (this is GEOS-2111). However GEOS-2111 is fiddly, and the problematic constructor is referenced in 17 places.

As a simpler alternative, symptomatic relief may be obtained by adding a ternary operator null pointer check for "descriptor" at line 71 in org.opengis.feature.IllegalAttributeException. Merely change

return ((message != null) ? (s + ": " + message) : s) + ": "descriptor.getName()" value:"+value ;

to

return ((message Unable to render embedded object: File ( " + message) : s) + ": "+((descriptor) not found.=null)?descriptor.getName():null)+" value:"+value;

This change should be applied to GeoAPI 2.2 and all higher branches. And a new SNAPSHOT release would be a nice touch.

Issue Links

Activity

Hide
Ben Caradoc-Davies added a comment -

Oops, all references above should be to GEOT-2111. Jira won't let me edit this issue, even though I reported it. And perhaps assign it to Jody, who fled from GEOT-2111.

Show
Ben Caradoc-Davies added a comment - Oops, all references above should be to GEOT-2111. Jira won't let me edit this issue, even though I reported it. And perhaps assign it to Jody, who fled from GEOT-2111.
Hide
Ben Caradoc-Davies added a comment -

And note also that Jira has mangled the code snippet. Just use a ternary operator test for null descriptor.

Show
Ben Caradoc-Davies added a comment - And note also that Jira has mangled the code snippet. Just use a ternary operator test for null descriptor.
Hide
Martin Desruisseaux added a comment -

Checking is the source code of IllegalAttributeException.toString(), this bug appears to be already fixed. Assigning to Jody since he is the author of this class and closing.

Show
Martin Desruisseaux added a comment - Checking is the source code of IllegalAttributeException.toString(), this bug appears to be already fixed. Assigning to Jody since he is the author of this class and closing.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: