You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/05/25 05:00:51 UTC

[GitHub] [flink] cyq89051127 commented on a change in pull request #12289: [FLINK-17874][Connectors/HBase]Handling the NPE for hbase-connector

cyq89051127 commented on a change in pull request #12289:
URL: https://github.com/apache/flink/pull/12289#discussion_r429731685



##########
File path: flink-connectors/flink-hbase/src/main/java/org/apache/flink/addons/hbase/util/HBaseTypeUtils.java
##########
@@ -81,13 +81,16 @@ public static Object deserializeToObject(byte[] value, int typeIdx, Charset stri
 	 * Serialize the Java Object to byte array with the given type.
 	 */
 	public static byte[] serializeFromObject(Object value, int typeIdx, Charset stringCharset) {
+		if (value == null){
+			return EMPTY_BYTES;

Review comment:
       @wuchong ,hi , i check the code, when deserializeToObject called, there could be a same problem. But when i dig deeper, It seems ok. 
   
   There're two place where `deserializeToObject` is called.
   One(I think it's ok) is like the following in `HBaseReadWriteHelper.parseToRow(Result result, Object rowKey`):
   ```java
       if (value != null) {					
             familyRow.setField(q, HBaseTypeUtils.deserializeToObject(value, typeIdx, charset));
        } else {
   	familyRow.setField(q, null);
       }
   ```
   
   The other one also looks good (in `HBaseReadWriteHelper.parseToRow(Result result)`) : 
   
   ```java 
   public Row parseToRow(Result result) {
   		if (rowKeyIndex == -1) {
   			return parseToRow(result, null);
   		} else {
   			Object rowkey = HBaseTypeUtils.deserializeToObject(result.getRow(), rowKeyType, charset);
   			return parseToRow(result, rowkey);
   		}
   	}
   ```
   
   I can't think of a scenario that result.getRow could return a null value because this code is used to parse the returned value form hbase with a scan command. 
   Do you have any suggestion?
   




----------------------------------------------------------------
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