You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by GitBox <gi...@apache.org> on 2021/03/16 11:02:54 UTC

[GitHub] [parquet-mr] gszadovszky opened a new pull request #881: PARQUET-1999: NPE might occur if OutputFile is implemented by the client

gszadovszky opened a new pull request #881:
URL: https://github.com/apache/parquet-mr/pull/881


   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [ ] My PR addresses the following [Parquet Jira](https://issues.apache.org/jira/browse/PARQUET/) issues and references them in the PR title. For example, "PARQUET-1234: My Parquet PR"
     - https://issues.apache.org/jira/browse/PARQUET-XXX
     - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Tests
   
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   ### Commits
   
   - [ ] My commits all reference Jira issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [ ] In case of new functionality, my PR adds documentation that describes how to use it.
     - All the public functions and the classes in the PR contain Javadoc that explain what it does
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [parquet-mr] shangxinli commented on pull request #881: PARQUET-1999: NPE might occur if OutputFile is implemented by the client

Posted by GitBox <gi...@apache.org>.
shangxinli commented on pull request #881:
URL: https://github.com/apache/parquet-mr/pull/881#issuecomment-800368372


   LGTM now


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [parquet-mr] shangxinli merged pull request #881: PARQUET-1999: NPE might occur if OutputFile is implemented by the client

Posted by GitBox <gi...@apache.org>.
shangxinli merged pull request #881:
URL: https://github.com/apache/parquet-mr/pull/881


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [parquet-mr] gszadovszky commented on a change in pull request #881: PARQUET-1999: NPE might occur if OutputFile is implemented by the client

Posted by GitBox <gi...@apache.org>.
gszadovszky commented on a change in pull request #881:
URL: https://github.com/apache/parquet-mr/pull/881#discussion_r595282860



##########
File path: parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetWriter.java
##########
@@ -281,8 +281,9 @@ public ParquetWriter(Path file, Configuration conf, WriteSupport<T> writeSupport
 
     // encryptionProperties could be built from the implementation of EncryptionPropertiesFactory when it is attached.
     if (encryptionProperties == null) {
+      String path = file == null ? null : file.getPath();
       encryptionProperties = ParquetOutputFormat.createEncryptionProperties(conf,
-          file == null ? null : new Path(file.getPath()), writeContext);
+          path == null ? null : new Path(path), writeContext);

Review comment:
       We are not checking the same twice. Once, we are checking the argument `file` if it is `null` then we are checking if the value returned by `file.getPath()` is `null`. (The latter check was missing and that caused the issue.)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [parquet-mr] shangxinli commented on a change in pull request #881: PARQUET-1999: NPE might occur if OutputFile is implemented by the client

Posted by GitBox <gi...@apache.org>.
shangxinli commented on a change in pull request #881:
URL: https://github.com/apache/parquet-mr/pull/881#discussion_r595286914



##########
File path: parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetWriter.java
##########
@@ -281,8 +281,9 @@ public ParquetWriter(Path file, Configuration conf, WriteSupport<T> writeSupport
 
     // encryptionProperties could be built from the implementation of EncryptionPropertiesFactory when it is attached.
     if (encryptionProperties == null) {
+      String path = file == null ? null : file.getPath();
       encryptionProperties = ParquetOutputFormat.createEncryptionProperties(conf,
-          file == null ? null : new Path(file.getPath()), writeContext);
+          path == null ? null : new Path(path), writeContext);

Review comment:
       Got it. Thanks for the clarification. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [parquet-mr] shangxinli commented on a change in pull request #881: PARQUET-1999: NPE might occur if OutputFile is implemented by the client

Posted by GitBox <gi...@apache.org>.
shangxinli commented on a change in pull request #881:
URL: https://github.com/apache/parquet-mr/pull/881#discussion_r595227345



##########
File path: parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetWriter.java
##########
@@ -281,8 +281,9 @@ public ParquetWriter(Path file, Configuration conf, WriteSupport<T> writeSupport
 
     // encryptionProperties could be built from the implementation of EncryptionPropertiesFactory when it is attached.
     if (encryptionProperties == null) {
+      String path = file == null ? null : file.getPath();
       encryptionProperties = ParquetOutputFormat.createEncryptionProperties(conf,
-          file == null ? null : new Path(file.getPath()), writeContext);
+          path == null ? null : new Path(path), writeContext);

Review comment:
       Instead of checking 'null' twice, can we do it like this? 
   Path path = (file == null) ? null : new Path(file.getPath());




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org