shaofengshi commented on a change in pull request #262: KYLIN-3597 Improve code 
smell
URL: https://github.com/apache/kylin/pull/262#discussion_r221114732
 
 

 ##########
 File path: 
core-storage/src/main/java/org/apache/kylin/storage/gtrecord/SegmentCubeTupleIterator.java
 ##########
 @@ -98,14 +98,23 @@ public GTInfo getInfo() {
                     return scanRequest.getInfo();
                 }
 
-                public void close() throws IOException {}
+                public void close() {
+                    // Underlying resource is hold by scanner and it will be 
closed at
+                    // SegmentCubeTupleIterator#close, caller is 
SequentialCubeTupleIterator
+                }
 
                 public Iterator<GTRecord> iterator() {
                     return records;
                 }
             };
-            GTStreamAggregateScanner aggregator = new 
GTStreamAggregateScanner(inputScanner, scanRequest);
-            return aggregator.valuesIterator(gtDimsIdx, gtMetricsIdx);
+            Iterator<Object[]> result;
+            try (GTStreamAggregateScanner aggregator = new 
GTStreamAggregateScanner(inputScanner, scanRequest)) {
+                result = aggregator.valuesIterator(gtDimsIdx, gtMetricsIdx);
+            } catch (IOException ioe) {
+                // implementation of close method of anonymous IGTScanner is 
empty, no way throw exception
+                throw new RuntimeException("IOException is not expected 
here.", ioe);
 
 Review comment:
   RuntimeException should be avoided; use a specific exception.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to