From c898a0997c109e2afe09004a6775c52544ce45da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Tue, 19 Dec 2023 15:48:12 +0100 Subject: [PATCH] fix: remove the `inputstream.ready()` check on the XmlReader This check fails in GCS even for all input streams. --- .../kestra/plugin/serdes/xml/XmlReader.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/kestra/plugin/serdes/xml/XmlReader.java b/src/main/java/io/kestra/plugin/serdes/xml/XmlReader.java index e42270f..4f2f0ea 100644 --- a/src/main/java/io/kestra/plugin/serdes/xml/XmlReader.java +++ b/src/main/java/io/kestra/plugin/serdes/xml/XmlReader.java @@ -74,31 +74,29 @@ public Output run(RunContext runContext) throws Exception { BufferedReader input = new BufferedReader(new InputStreamReader(runContext.uriToInputStream(from), charset)); OutputStream output = new FileOutputStream(tempFile); ) { - if(input.ready()) { - XMLParserConfiguration xmlParserConfiguration = new XMLParserConfiguration(); - if (parserConfiguration != null) { - xmlParserConfiguration = xmlParserConfiguration.withForceList(parserConfiguration.getForceList()); - } - JSONObject jsonObject = XML.toJSONObject(input, xmlParserConfiguration); - - Object result = result(jsonObject); - - if (result instanceof JSONObject) { - Map map = ((JSONObject) result).toMap(); - FileSerde.write(output, map); - runContext.metric(Counter.of("records", map.size())); - } else if (result instanceof JSONArray) { - List list = ((JSONArray) result).toList(); - list.forEach(throwConsumer(o -> { - FileSerde.write(output, o); - })); - runContext.metric(Counter.of("records", list.size())); - } else { - FileSerde.write(output, result); - } - - output.flush(); + XMLParserConfiguration xmlParserConfiguration = new XMLParserConfiguration(); + if (parserConfiguration != null) { + xmlParserConfiguration = xmlParserConfiguration.withForceList(parserConfiguration.getForceList()); } + JSONObject jsonObject = XML.toJSONObject(input, xmlParserConfiguration); + + Object result = result(jsonObject); + + if (result instanceof JSONObject) { + Map map = ((JSONObject) result).toMap(); + FileSerde.write(output, map); + runContext.metric(Counter.of("records", map.size())); + } else if (result instanceof JSONArray) { + List list = ((JSONArray) result).toList(); + list.forEach(throwConsumer(o -> { + FileSerde.write(output, o); + })); + runContext.metric(Counter.of("records", list.size())); + } else { + FileSerde.write(output, result); + } + + output.flush(); } return Output