Repository: incubator-carbondata
Updated Branches:
  refs/heads/master 381b08a01 -> 7147be281


if for any reason data load is failed during the dictionary generation then in 
the finally block trying to write the meta file but as the stream is null, it 
will throw null pointer.


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/ebe987b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/ebe987b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/ebe987b2

Branch: refs/heads/master
Commit: ebe987b22a92090a91471534711a63187081f907
Parents: 381b08a
Author: ravikiran <ravikiran.sn...@gmail.com>
Authored: Sat Sep 17 00:04:38 2016 +0530
Committer: Venkata Ramana G <ramana.gollam...@huawei.com>
Committed: Sun Sep 18 02:37:52 2016 +0530

----------------------------------------------------------------------
 .../core/writer/CarbonDictionaryWriterImpl.java          |  5 +++--
 .../org/apache/carbondata/core/writer/ThriftWriter.java  | 11 +++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ebe987b2/core/src/main/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImpl.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImpl.java
 
b/core/src/main/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImpl.java
index 316832d..fab8db4 100644
--- 
a/core/src/main/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImpl.java
+++ 
b/core/src/main/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImpl.java
@@ -198,7 +198,8 @@ public class CarbonDictionaryWriterImpl implements 
CarbonDictionaryWriter {
    * @throws IOException if an I/O error occurs
    */
   @Override public void close() throws IOException {
-    if (null != dictionaryThriftWriter) {
+    if (null != dictionaryThriftWriter && dictionaryThriftWriter.isOpen()) {
+      // if stream is open then only need to write dictionary file.
       writeDictionaryFile();
       // close the thrift writer for dictionary file
       closeThriftWriter();
@@ -404,7 +405,7 @@ public class CarbonDictionaryWriterImpl implements 
CarbonDictionaryWriter {
   }
 
   @Override public void commit() throws IOException {
-    if (null != dictionaryThriftWriter) {
+    if (null != dictionaryThriftWriter && dictionaryThriftWriter.isOpen()) {
       this.chunk_end_offset = CarbonUtil.getFileSize(this.dictionaryFilePath);
       writeDictionaryMetadataFile();
     }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ebe987b2/core/src/main/java/org/apache/carbondata/core/writer/ThriftWriter.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/carbondata/core/writer/ThriftWriter.java 
b/core/src/main/java/org/apache/carbondata/core/writer/ThriftWriter.java
index c232fb2..93b17f3 100644
--- a/core/src/main/java/org/apache/carbondata/core/writer/ThriftWriter.java
+++ b/core/src/main/java/org/apache/carbondata/core/writer/ThriftWriter.java
@@ -80,6 +80,17 @@ public class ThriftWriter {
   }
 
   /**
+   * This will check whether stream and binary out is open or not.
+   * @return
+   */
+  public boolean isOpen() {
+    if (null != binaryOut && null != dataOutputStream) {
+      return true;
+    }
+    return false;
+  }
+
+  /**
    * Write the object to disk.
    */
   public void write(TBase t) throws IOException {

Reply via email to