[jboss-jira] [JBoss JIRA] (DROOLS-546) FactType.get/set should throw specific exception (not NPE) for unknown fields

Davide Sottara (JIRA) issues at jboss.org
Mon Jul 7 18:51:24 EDT 2014


    [ https://issues.jboss.org/browse/DROOLS-546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12982825#comment-12982825 ] 

Davide Sottara commented on DROOLS-546:
---------------------------------------

There are a number of places where data-model related exceptions could be thrown. One for all, the getFactType() call in the first place should behave consistently.
Right now, it returns null when the type does not exist, so Mario's fix is at least consistent.
We had a discussion on whether methods such as "hasField(String) : boolean" or hasType(String,String) : boolean" should be included as a compromise. That would
be an API change, though a purely additive one.

The real problem is more foundational: we currently don't have type-safe access to the declared classes. This issue will hopefully be fixed in Drools 6.2.
Davide


> FactType.get/set should throw specific exception (not NPE) for unknown fields
> -----------------------------------------------------------------------------
>
>                 Key: DROOLS-546
>                 URL: https://issues.jboss.org/browse/DROOLS-546
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 6.1.0.CR1
>            Reporter: Benoit Voisin
>            Assignee: Mario Fusco
>             Fix For: 6.1.0.Final
>
>
> factType.get(instance, "unknownField") is currently throwing an NPE. This gives improper information to the user/developper.
> I propose that it throws a new UnknownFactFieldException giving improved information giving good hints for debugging or enabling specific exception management.
> See pull request for test-case and proposed fix



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the jboss-jira mailing list