You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by jo...@apache.org on 2020/12/07 20:24:57 UTC

[arrow] branch master updated: ARROW-10830 [Rust] avoid hard crash in json reader

This is an automated email from the ASF dual-hosted git repository.

jorgecarleitao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new b290e23  ARROW-10830 [Rust] avoid hard crash in json reader
b290e23 is described below

commit b290e2352489b327a845717bdeb81b89e5d99205
Author: Qingping Hou <da...@gmail.com>
AuthorDate: Mon Dec 7 21:23:14 2020 +0100

    ARROW-10830 [Rust] avoid hard crash in json reader
    
    return parsing error to caller instead
    
    Closes #8858 from houqp/qp_json_error
    
    Authored-by: Qingping Hou <da...@gmail.com>
    Signed-off-by: Jorge C. Leitao <jo...@gmail.com>
---
 rust/arrow/src/json/reader.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rust/arrow/src/json/reader.rs b/rust/arrow/src/json/reader.rs
index 5543eda..118c52c 100644
--- a/rust/arrow/src/json/reader.rs
+++ b/rust/arrow/src/json/reader.rs
@@ -472,7 +472,9 @@ impl<R: Read> Reader<R> {
         for _ in 0..self.batch_size {
             let bytes_read = self.reader.read_line(&mut line)?;
             if bytes_read > 0 {
-                rows.push(serde_json::from_str(&line).expect("Not valid JSON"));
+                rows.push(serde_json::from_str(&line).map_err(|e| {
+                    ArrowError::JsonError(format!("Not valid JSON: {}", e))
+                })?);
                 line = String::new();
             } else {
                 break;