Bug 1061954

Summary: NPE when calling system.listActiveSystemsDetails API method
Product: [Community] Spacewalk Reporter: Shannon Hughes <shughes>
Component: APIAssignee: Milan Zázrivec <mzazrivec>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 2.1CC: cperry, xdmoon
Target Milestone: ---Keywords: Patch, Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-04 13:07:44 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:
Bug Depends On:    
Bug Blocks: 1069560    
Attachments:
Description Flags
patch to correct null pointer xmlrpc faults none

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 SystemHandler.java 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/Parser.pm 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.
https://fedorahosted.org/spacewalk/wiki/ReleaseNotes21

Comment 3 Matej Kollar 2014-03-04 13:08:54 UTC
Spacewalk 2.1 has been released.
https://fedorahosted.org/spacewalk/wiki/ReleaseNotes21