Bug 1119731

Summary: Missing null check in legacy api causing nullpointerexception
Product: [Retired] JBoss BRMS Platform 6 Reporter: Anton Giertli <agiertli>
Component: BREAssignee: Mario Fusco <mfusco>
Status: CLOSED EOL QA Contact: Marek Winkler <mwinkler>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.1CC: mfusco
Target Milestone: DR2   
Target Release: 6.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 20:07:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
[0] reproducer none

Description Anton Giertli 2014-07-15 11:51:20 UTC
Created attachment 918147 [details]
[0] reproducer

Description of problem:


If you try to retrieve FactHandle for an object which is **not** present in the KnowledgeSession this fact handle will not have null value.

There, if you call

if (handle!=null)
ksession.update(handle,object);

you will receive NPE

Version-Release number of selected component (if applicable):


How reproducible:
always

Steps to Reproduce:
1. Just execute the reproducer with the Drools 6 libraries - i.e. knowledge-api legacy adapter

Actual results:

	FactHandle handle = ksession.getFactHandle(msg1);

handle is not null even if the msg1 object is NOT present in the session.

Expected results:
	FactHandle handle = ksession.getFactHandle(msg1);

handle should be null if the msg1 object is not present in the session

Additional info:

Root cause seems to be the missing nullcheck in the following method
https://github.com/droolsjbpm/drools/blob/master/knowledge-api-legacy5-adapter/src/main/java/org/drools/impl/adapters/WorkingMemoryEntryPointAdapter.java#L47

Comment 2 Mario Fusco 2014-07-15 15:14:53 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/386dce144

Comment 3 Marek Winkler 2014-09-29 10:58:05 UTC
Verified with BRMS 6.1.0.DR3.