[#86] Fixed the case when an exception is thrown for XML processing

This commit is contained in:
Marcin Grzejszczak
2015-06-18 18:44:57 +02:00
parent 2f5f9f5349
commit f74e86ce5d

View File

@@ -51,12 +51,19 @@ class ContentUtils {
return extractValueForXML(bodyAsValue, valueProvider)
} catch (Exception exception) {
log.debug("No content type provided and failed to parse as XML - returning the value back to the user", exception)
return bodyAsValue
return extractValueForGString(bodyAsValue, valueProvider)
}
}
}
private static GStringImpl extractValueForGString(GString bodyAsValue, Closure valueProvider) {
return new GStringImpl(
bodyAsValue.values.collect { it instanceof DslProperty ? valueProvider(it) : it } as String[],
bodyAsValue.strings.clone() as String[]
)
}
public static Object extractValue(GString bodyAsValue, Closure valueProvider) {
return extractValue(bodyAsValue, ContentType.UNKNOWN, valueProvider)
}