Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1061954 - NPE when calling system.listActiveSystemsDetails API method
Summary: NPE when calling system.listActiveSystemsDetails API method
Alias: None
Product: Spacewalk
Classification: Community
Component: API
Version: 2.1
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Milan Zázrivec
QA Contact: Red Hat Satellite QA List
Depends On:
Blocks: space21
TreeView+ depends on / blocked
Reported: 2014-02-05 22:49 UTC by Shannon Hughes
Modified: 2015-04-15 22:50 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2014-03-04 13:07:44 UTC

Attachments (Terms of Use)
patch to correct null pointer xmlrpc faults (deleted)
2014-02-05 22:49 UTC, Shannon Hughes
no flags Details | Diff

System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1061484 None None None Never

Internal Links: 1061484

Description Shannon Hughes 2014-02-05 22:49:31 UTC
Created attachment 859904 [details]
patch to correct null pointer xmlrpc faults

Systems registered with the --nohardware flag cause a null pointer exception when using the api listActiveSystemsDetails. The class does not handle null values for the DMI info, CPU, RAM or Swap and causes a xmlrpc fault: 

XML or text declaration not at start of entity at line 35, column 76, byte 3983 at /usr/lib64/perl5/vendor_perl/XML/ line 187
</value></data></array></value></member><member><name>dmi_info</name><value><?xml version="1.0" encoding="UTF-8"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>-1</int></value></member><member><name>faultString</name><value><string>java.lang.NullPointerException: null</string></value></member></struct></value></fault></methodResponse>

attaching a patch that correctly sets the structs to empty Hashmaps and instantiates Longs for RAM/Swap. 

Duplicator steps: 

1) register a system with the --nohardware or force register existing systems
2) create a api script to call the system with no records in rhnServerDMI, rhnCPU, etc. 
3) Observe the XMLRPC fault

Sample perl api script for testing

#!/usr/bin/perl -w 

use strict; 
use Frontier::Client; 

my $HOST = 'sat560.sat.lan';
my $USER = 'admin';
my $PASS = 'redhat';

my $client = new Frontier::Client(url => "http://$HOST/rpc/api", debug=>1);
my $session = $client->call('auth.login', $USER, $PASS);

my $ref = [1000010017];
my $foo =  $client->call('system.listActiveSystemsDetails',$session, $ref);

Comment 1 Milan Zázrivec 2014-02-06 06:59:58 UTC
Patch applied in spacewalk.git master: f72f426327a1006e215ab5e7cb39b7b3b24da410

Comment 2 Matej Kollar 2014-03-04 13:07:44 UTC
Spacewalk 2.1 has been released.

Comment 3 Matej Kollar 2014-03-04 13:08:54 UTC
Spacewalk 2.1 has been released.

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