Review Board 1.7.22


SQOOP-827 Sqoop2: MMapInput is null while retrieving from DB if pass empty map on write

Review Request #13385 - Created Aug. 7, 2013 and submitted

Mengwei Ding
SQOOP-827
Reviewers
Sqoop
abe, hshreedharan, jarcec
sqoop-sqoop2
commit d354e88d56123b0a331179d41ad2df2eb5d02ba4
Author: Mengwei Ding <mengwei.ding@gmail.com>
Date:   Tue Aug 6 16:23:17 2013 -0700

    SQOOP-827 Sqoop2: MMapInput is null while retrieving from DB if pass empty map on write

:100644 100644 de17e2d... 37dd265... M	common/src/main/java/org/apache/sqoop/model/MMapInput.java
:100644 100644 eb877cf... 120fb07... M	common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
:100644 100644 8a5aee8... a2a0bc7... M	repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
:100644 100644 6959f2d... f9e9217... M	repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
:100644 100644 a3d804e... 4325c5c... M	repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java

 
common/src/main/java/org/apache/sqoop/model/MMapInput.java
Revision de17e2d New Change
[20] 29 lines
[+20]
30
  }
30
  }
31

    
   
31

   
32
  @Override
32
  @Override
33
  public String getUrlSafeValueString() {
33
  public String getUrlSafeValueString() {
34
    Map<String, String> valueMap = getValue();
34
    Map<String, String> valueMap = getValue();
35
    if (valueMap == null || valueMap.size() == 0) {
35
    if (valueMap == null) {
36
      return "";
36
      return null;
37
    }
37
    }
38
    boolean first = true;
38
    boolean first = true;
39
    StringBuilder vsb = new StringBuilder();
39
    StringBuilder vsb = new StringBuilder();
40
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
40
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
41
      if (first) {
41
      if (first) {
[+20] [20] 7 lines
[+20] public String getUrlSafeValueString() {
49
    return vsb.toString();
49
    return vsb.toString();
50
  }
50
  }
51

    
   
51

   
52
  @Override
52
  @Override
53
  public void restoreFromUrlSafeValueString(String valueString) {
53
  public void restoreFromUrlSafeValueString(String valueString) {
54
    Map<String, String> valueMap = null;
54
    if (valueString == null) {
55
    if (valueString != null && valueString.trim().length() > 0) {
55
      setValue(null);
56
      valueMap = new HashMap<String, String>();
56
    } else {

    
   
57
      Map<String, String> valueMap = new HashMap<String, String>();

    
   
58
      if (valueString.trim().length() > 0) {
57
      String[] valuePairs = valueString.split("&");
59
        String[] valuePairs = valueString.split("&");
58
      for (String pair : valuePairs) {
60
        for (String pair : valuePairs) {
59
        String[] nameAndVal = pair.split("=");
61
          String[] nameAndVal = pair.split("=");
60
        if (nameAndVal.length > 0) {
62
          if (nameAndVal.length > 0) {
61
          String name = nameAndVal[0];
63
            String name = nameAndVal[0];
[+20] [20] 6 lines
[+20] public String getUrlSafeValueString() {
68
        }
70
          }
69
      }
71
        }
70
    }
72
      }
71
    setValue(valueMap);
73
      setValue(valueMap);
72
  }
74
    }

    
   
75
  }
73

    
   
76

   
74
  @Override
77
  @Override
75
  public MInputType getType() {
78
  public MInputType getType() {
76
    return MInputType.MAP;
79
    return MInputType.MAP;
77
  }
80
  }
[+20] [20] 45 lines
common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
Revision eb877cf New Change
 
repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
Revision 8a5aee8 New Change
 
repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
Revision 6959f2d New Change
 
repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
Revision a3d804e New Change
 
  1. common/src/main/java/org/apache/sqoop/model/MMapInput.java: Loading...
  2. common/src/test/java/org/apache/sqoop/model/TestMMapInput.java: Loading...
  3. repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java: Loading...
  4. repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java: Loading...
  5. repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java: Loading...