Fix issue with empty xml resulting in parse errors.
This commit is contained in:
parent
804b49b86d
commit
c1c894d64e
|
@ -1,2 +1,2 @@
|
|||
group = biz.nellemann.hmci
|
||||
version = 1.0.7
|
||||
version = 1.0.8
|
||||
|
|
|
@ -149,6 +149,11 @@ class HmcClient {
|
|||
String responseBody = response.body.string()
|
||||
Map<String,ManagedSystem> managedSystemsMap = new HashMap<String, ManagedSystem>()
|
||||
|
||||
// Do not try to parse empty response
|
||||
if(responseBody.empty || responseBody.size() < 1) {
|
||||
return managedSystemsMap
|
||||
}
|
||||
|
||||
def feed = new XmlSlurper().parseText(responseBody)
|
||||
feed?.entry?.each { entry ->
|
||||
entry.content.each { content ->
|
||||
|
@ -182,8 +187,13 @@ class HmcClient {
|
|||
URL url = new URL(String.format("%s/rest/api/uom/ManagedSystem/%s/LogicalPartition", baseUrl, system.id))
|
||||
Response response = getResponse(url)
|
||||
String responseBody = response.body.string()
|
||||
|
||||
Map<String, LogicalPartition> partitionMap = new HashMap<String, LogicalPartition>() {}
|
||||
|
||||
// Do not try to parse empty response
|
||||
if(responseBody.empty || responseBody.size() < 1) {
|
||||
return partitionMap
|
||||
}
|
||||
|
||||
def feed = new XmlSlurper().parseText(responseBody)
|
||||
feed?.entry?.each { entry ->
|
||||
//log.debug("Entry")
|
||||
|
|
|
@ -21,6 +21,18 @@ class HmcClientTest extends Specification {
|
|||
mockServer.shutdown()
|
||||
}
|
||||
|
||||
void "test against empty xml"() {
|
||||
setup:
|
||||
def testXml = ""
|
||||
mockServer.enqueue(new MockResponse().setBody(testXml));
|
||||
|
||||
when:
|
||||
Map<String, ManagedSystem> systems = hmc.getManagedSystems()
|
||||
|
||||
then:
|
||||
systems.size() == 0
|
||||
}
|
||||
|
||||
|
||||
void "test getManagedSystems"() {
|
||||
setup:
|
||||
|
|
Loading…
Reference in a new issue