[jboss-jira] [JBoss JIRA] Resolved: (JBRULES-2588) Error creates null package without generating error message
Mark Proctor (JIRA)
jira-events at lists.jboss.org
Tue May 17 17:02:01 EDT 2011
[ https://issues.jboss.org/browse/JBRULES-2588?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Proctor resolved JBRULES-2588.
-----------------------------------
Resolution: Done
I've adde the following null check:
if ( pkg == null ) {
this.results.add( new ParserError( "Parser returned a null Package", 0, 0 ) );
}
> Error creates null package without generating error message
> -----------------------------------------------------------
>
> Key: JBRULES-2588
> URL: https://issues.jboss.org/browse/JBRULES-2588
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-compiler
> Affects Versions: 5.0.1.FINAL
> Environment: Windows XP/Eclipse Ganymeade
> Reporter: Thomas Hehl
> Assignee: Mark Proctor
> Priority: Minor
> Fix For: 5.2.0.CR1
>
> Original Estimate: 30 minutes
> Remaining Estimate: 30 minutes
>
> PackageBuilder contains the following method:
> public void addPackageFromDrl(final Reader reader) throws DroolsParserException,
> IOException {
> this.resource = new ReaderResource( reader );
> final DrlParser parser = new DrlParser();
> final PackageDescr pkg = parser.parse( reader );
> this.results.addAll( parser.getErrors() );
> if ( !parser.hasErrors() ) {
> addPackage( pkg );
> }
> this.resource = null;
> }
> The problem is that if the parser generates errors, then the package is null and my application blows up later on with a null pointer exception, but the error messages are lost.
> To fix this problem I recommend a code change like:
> public void addPackageFromDrl(final Reader reader) throws DroolsParserException,
> IOException {
> this.resource = new ReaderResource( reader );
> final DrlParser parser = new DrlParser();
> final PackageDescr pkg = parser.parse( reader );
> this.results.addAll( parser.getErrors() );
> if ( parser.hasErrors() ) {
> System.err.println("Parser errors generating null package:" + this.results.toString());
> else{
> addPackage( pkg );
> }
> this.resource = null;
> }
> This will cause an error dump in the log without changing any functionality.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list