Skip to content

Commit

Permalink
Don't add file content to the exception when requesting XML documents…
Browse files Browse the repository at this point in the history
…, if the content is not XML (#8360)
  • Loading branch information
josegar74 committed Sep 9, 2024
1 parent d560b2a commit 39838a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/src/main/java/org/fao/geonet/utils/XmlRequest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down Expand Up @@ -124,13 +124,13 @@ protected final Element executeAndReadResponse(HttpRequestBase httpMethod) throw
" -- Response Code: " + httpResponse.getRawStatusCode());
}

byte[] data = null;
byte[] data;

try {
data = IOUtils.toByteArray(httpResponse.getBody());
return Xml.loadStream(new ByteArrayInputStream(data));
} catch (JDOMException e) {
throw new BadXmlResponseEx("Response: '" + new String(data, "UTF8") + "' (from URI " + httpMethod.getURI() + ")");
throw new BadXmlResponseEx("Invalid XML document from URI: " + httpMethod.getURI());
} finally {
httpMethod.releaseConnection();

Expand Down

0 comments on commit 39838a9

Please sign in to comment.