[ 
https://issues.apache.org/jira/browse/DRILL-6724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603032#comment-16603032
 ] 

ASF GitHub Bot commented on DRILL-6724:
---------------------------------------

vdiravka commented on a change in pull request #1455: DRILL-6724: Convert 
IndexOutOfBounds exception to UserException with …
URL: https://github.com/apache/drill/pull/1455#discussion_r214905003
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader.java
 ##########
 @@ -205,36 +191,32 @@ public int next() {
     writer.reset();
     recordCount = 0;
     parseErrorCount = 0;
-    if(write == ReadState.JSON_RECORD_PARSE_EOF_ERROR){
+    if (write == ReadState.JSON_RECORD_PARSE_EOF_ERROR) {
       return recordCount;
     }
-    outside: while(recordCount < DEFAULT_ROWS_PER_BATCH){
-      try{
+    while (recordCount < DEFAULT_ROWS_PER_BATCH) {
+      try {
         writer.setPosition(recordCount);
         write = jsonReader.write(writer);
-        if(write == ReadState.WRITE_SUCCEED){
+        if (write == ReadState.WRITE_SUCCEED) {
           recordCount++;
-        }
-        else if(write == ReadState.JSON_RECORD_PARSE_ERROR || write == 
ReadState.JSON_RECORD_PARSE_EOF_ERROR){
-          if(skipMalformedJSONRecords == false){
-            handleAndRaise("Error parsing JSON", new 
Exception(hadoopPath.getName() + " : line nos :" + (recordCount+1)));
+        } else if (write == ReadState.JSON_RECORD_PARSE_ERROR || write == 
ReadState.JSON_RECORD_PARSE_EOF_ERROR) {
+          if (!skipMalformedJSONRecords) {
+            handleAndRaise("Error parsing JSON", new Exception());
           }
           ++parseErrorCount;
-          if(printSkippedMalformedJSONRecordLineNumber){
-            logger.debug("Error parsing JSON in " + hadoopPath.getName() + " : 
line nos :" + (recordCount+parseErrorCount));
+          if (printSkippedMalformedJSONRecordLineNumber) {
+            logger.debug("Error parsing JSON in " + hadoopPath.getName() + " : 
line nos :" + (recordCount + parseErrorCount));
           }
-          if(write == ReadState.JSON_RECORD_PARSE_EOF_ERROR){
-            break outside;
+          if (write == ReadState.JSON_RECORD_PARSE_EOF_ERROR) {
+            break;
           }
+        } else {
+          break;
         }
-        else{
-          break outside;
-        }
+      } catch(IOException ex) {
 
 Review comment:
   space after `catch`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Convert IndexOutOfBounds exception to UserException with context data where 
> possible
> ------------------------------------------------------------------------------------
>
>                 Key: DRILL-6724
>                 URL: https://issues.apache.org/jira/browse/DRILL-6724
>             Project: Apache Drill
>          Issue Type: Improvement
>    Affects Versions: 1.14.0
>            Reporter: Bohdan Kazydub
>            Assignee: Bohdan Kazydub
>            Priority: Major
>             Fix For: 1.15.0
>
>
> Sometimes when IndexOutOfBoundsException is exposed to users it is not clear 
> what causes the problem. Instead this exception may be converted to a more 
> useful UserException containing context data like filename, line, position 
> etc (depending on what is available from a reader for a given type).
> A possible approach is to add a method to a RecordReader interface which 
> produces UserException of type ErrorType.DATA_READ with context data, so that 
> when such an UserException is needed it can be easily obtained by invoking 
> the method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to