Bug 478176 - MIGRATED_FROM_JIRA: Nested mapping throws NPE
Summary: MIGRATED_FROM_JIRA: Nested mapping throws NPE
Keywords:
Status: CLOSED EOL
Alias: None
Product: penrose
Classification: Retired
Component: Engine
Version: 2.0
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Endi Sukma Dewata
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks: 471500
TreeView+ depends on / blocked
 
Reported: 2008-12-27 08:06 UTC by Chandrasekar Kannan
Modified: 2020-03-27 19:35 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-27 19:35:50 UTC
Embargoed:


Attachments (Terms of Use)

Description Chandrasekar Kannan 2008-12-27 08:06:21 UTC
The following mapping is throwing an NPE when I perform a search for the nested entry.

The query is:

InitialDirContext ctx = connect();
ctx.search("ou=XPT,ou=systems,o=teste", "ou=xhts", new SearchControls())

The db schema is pretty simple:

function(function_id, function_name, system_id)
system(system_id, system_desc)

The penrose mapping is:

  <entry dn="ou=...,ou=systems,o=test">
    <oc>organizationalUnit</oc>
    <oc>top</oc>
    <at name="ou" rdn="true">
      <variable>system.system_id</variable>
    </at>
    <at name="description">
      <variable>system.system_desc</variable>
    </at>
    <source name="system">
      <source-name>system</source-name>
      <field name="system_id">
        <variable>ou</variable>
      </field>
      <field name="system_desc">
        <variable>description</variable>
      </field>
    </source>
  </entry>
  
 <entry dn="ou=...,ou=...,ou=systems,o=test">
    <oc>organizationalUnit</oc>
    <oc>top</oc>
    <at name="ou" rdn="true">
      <variable>function.function_name</variable>
    </at>
    <at name="description">
      <variable>function.function_desc</variable>
    </at>
    
    <source name="function">
      <source-name>function</source-name>
      <field name="function_name">
        <variable>ou</variable>
      </field>
      <field name="system_id">
        <variable>parent.ou</variable>
      </field>
      <field name="function_name">
        <variable>description</variable>
      </field>
    </source>
     <relationship>
      <expression>system.system_id = function.system_id</expression>
    </relationship>
  </entry>

And, finally, the exception is:

java.lang.NullPointerException
	at org.safehaus.penrose.engine.LoadEngine.loadEntries(LoadEngine.java:308)
	at org.safehaus.penrose.engine.LoadEngine.loadBackground(LoadEngine.java:226)
	at org.safehaus.penrose.engine.LoadEngine.load(LoadEngine.java:106)
	at org.safehaus.penrose.engine.Engine.load(Engine.java:434)
	at org.safehaus.penrose.engine.DefaultEngine.expand(DefaultEngine.java:619)
	at org.safehaus.penrose.handler.SearchHandler.searchChildren(SearchHandler.java:297)
	at org.safehaus.penrose.handler.SearchHandler.search(SearchHandler.java:143)
	at org.safehaus.penrose.handler.Handler.searchInBackground(Handler.java:697)
	at org.safehaus.penrose.handler.Handler$1.run(Handler.java:567)
	at org.safehaus.penrose.thread.ThreadWorker.runIt(ThreadWorker.java:94)
	at org.safehaus.penrose.thread.ThreadWorker.runJobs(ThreadWorker.java:85)
	at org.safehaus.penrose.thread.ThreadWorker.access$0(ThreadWorker.java:72)
	at org.safehaus.penrose.thread.ThreadWorker$1.run(ThreadWorker.java:48)
	at java.lang.Thread.run(Thread.java:595)

By adding "if(attributeMappings != null)" before line 308 in LoadEngine.loadEntries the problem goes away and the expected result is returned, but I'm pretty clueless if this is the proper way to fix it.
Additional Comments From endisd dated Thu May 17 15:49:10 CDT 2007 
In Penrose 1.2 the nested mapping has been rewritten and the following notation is no longer supported and should be removed:

     <relationship>
      <expression>system.system_id = function.system_id</expression>
    </relationship>

Instead, the source relations should be specified inside the fields as follows:

<source name="function">
      <source-name>function</source-name>
      <field name="function_name">
        <variable>ou</variable>
      </field>
      <field name="system_id">
        <variable>system.system_id</variable>
      </field>
      <field name="function_name">
        <variable>description</variable>
      </field>
    </source>



=========================================================
Issue dump from jira
$VAR1 = {
          'priority' => '3',
          'customFieldValues' => [],
          'project' => 'PENROSE',
          'status' => '5',
          'components' => [
                            {
                              'name' => 'Engine',
                              'id' => '10009'
                            }
                          ],
          'reporter' => 'kumpera',
          'key' => 'PENROSE-202',
          'assignee' => 'jimyang',
          'summary' => 'Nested mapping throws NPE',
          'id' => '10605',
          'updated' => '2007-05-17 15:49:10.0',
          'votes' => '0',
          'fixVersions' => [
                           {
                             'releaseDate' => '2007-05-18 00:00:00.0',
                             'sequence' => '22',
                             'name' => 'Penrose-1.2',
                             'released' => 'true',
                             'id' => '10088',
                             'archived' => 'false'
                           }
                         ],
          'description' => 'The following mapping is throwing an NPE when I perform a search for the nested entry.

The query is:

InitialDirContext ctx = connect();
ctx.search("ou=XPT,ou=systems,o=teste", "ou=xhts", new SearchControls())

The db schema is pretty simple:

function(function_id, function_name, system_id)
system(system_id, system_desc)

The penrose mapping is:

  <entry dn="ou=...,ou=systems,o=test">
    <oc>organizationalUnit</oc>
    <oc>top</oc>
    <at name="ou" rdn="true">
      <variable>system.system_id</variable>
    </at>
    <at name="description">
      <variable>system.system_desc</variable>
    </at>
    <source name="system">
      <source-name>system</source-name>
      <field name="system_id">
        <variable>ou</variable>
      </field>
      <field name="system_desc">
        <variable>description</variable>
      </field>
    </source>
  </entry>
  
 <entry dn="ou=...,ou=...,ou=systems,o=test">
    <oc>organizationalUnit</oc>
    <oc>top</oc>
    <at name="ou" rdn="true">
      <variable>function.function_name</variable>
    </at>
    <at name="description">
      <variable>function.function_desc</variable>
    </at>
    
    <source name="function">
      <source-name>function</source-name>
      <field name="function_name">
        <variable>ou</variable>
      </field>
      <field name="system_id">
        <variable>parent.ou</variable>
      </field>
      <field name="function_name">
        <variable>description</variable>
      </field>
    </source>
     <relationship>
      <expression>system.system_id = function.system_id</expression>
    </relationship>
  </entry>

And, finally, the exception is:

java.lang.NullPointerException
	at org.safehaus.penrose.engine.LoadEngine.loadEntries(LoadEngine.java:308)
	at org.safehaus.penrose.engine.LoadEngine.loadBackground(LoadEngine.java:226)
	at org.safehaus.penrose.engine.LoadEngine.load(LoadEngine.java:106)
	at org.safehaus.penrose.engine.Engine.load(Engine.java:434)
	at org.safehaus.penrose.engine.DefaultEngine.expand(DefaultEngine.java:619)
	at org.safehaus.penrose.handler.SearchHandler.searchChildren(SearchHandler.java:297)
	at org.safehaus.penrose.handler.SearchHandler.search(SearchHandler.java:143)
	at org.safehaus.penrose.handler.Handler.searchInBackground(Handler.java:697)
	at org.safehaus.penrose.handler.Handler$1.run(Handler.java:567)
	at org.safehaus.penrose.thread.ThreadWorker.runIt(ThreadWorker.java:94)
	at org.safehaus.penrose.thread.ThreadWorker.runJobs(ThreadWorker.java:85)
	at org.safehaus.penrose.thread.ThreadWorker.access$0(ThreadWorker.java:72)
	at org.safehaus.penrose.thread.ThreadWorker$1.run(ThreadWorker.java:48)
	at java.lang.Thread.run(Thread.java:595)

By adding "if(attributeMappings != null)" before line 308 in LoadEngine.loadEntries the problem goes away and the expected result is returned, but I'm pretty clueless if this is the proper way to fix it.',
          'affectsVersions' => [
                               {
                                 'releaseDate' => '2006-11-27 00:00:00.0',
                                 'sequence' => '20',
                                 'name' => 'Penrose-1.1.2',
                                 'released' => 'true',
                                 'id' => '10091',
                                 'archived' => 'false'
                               }
                             ],
          'created' => '2007-02-22 13:01:12.0',
          'environment' => 'winXP, java 1.5.06, penrose 1.1.2',
          'resolution' => '1',
          'type' => '1'
        };


=========================================================

Comment 1 Chandrasekar Kannan 2008-12-27 08:06:23 UTC
Marking bug as MODIFIED as it was already resolved in Jira - PENROSE-202


Note You need to log in before you can comment on or make changes to this bug.