Skip to content

Commit 91e3d98

Browse files
committed
Merge pull request #208 from twitter/backportFixes
Backport fixes
2 parents 0363427 + 28d5b0f commit 91e3d98

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

chill-hadoop/src/main/java/com/twitter/chill/hadoop/KryoSerialization.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class KryoSerialization extends Configured implements Serialization<Objec
5050
* It will first call this, then setConf.
5151
*/
5252
public KryoSerialization() {
53-
this(new Configuration());
53+
super();
5454
}
5555

5656
/**
@@ -65,15 +65,18 @@ public KryoSerialization( Configuration conf ) {
6565

6666
@Override
6767
public void setConf(Configuration conf) {
68-
try {
69-
KryoInstantiator kryoInst = new ConfiguredInstantiator(new HadoopConfig(conf));
70-
testKryo = kryoInst.newKryo();
71-
kryoPool = KryoPool.withByteArrayOutputStream(MAX_CACHED_KRYO, kryoInst);
72-
}
73-
catch(ConfigurationException cx) {
74-
// This interface can't throw
75-
throw new RuntimeException(cx);
76-
}
68+
// null check is to handle when calling the defaul constructor, in Configured, it calls super which calls setConf with a null Configuration
69+
if (conf != null) {
70+
try {
71+
KryoInstantiator kryoInst = new ConfiguredInstantiator(new HadoopConfig(conf));
72+
testKryo = kryoInst.newKryo();
73+
kryoPool = KryoPool.withByteArrayOutputStream(MAX_CACHED_KRYO, kryoInst);
74+
}
75+
catch(ConfigurationException cx) {
76+
// This interface can't throw
77+
throw new RuntimeException(cx);
78+
}
79+
}
7780
}
7881

7982
/**

chill-java/src/main/java/com/twitter/chill/config/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String getOrElse(String key, String def) {
3131
}
3232

3333
public boolean contains(String key) {
34-
return get(key) == null;
34+
return get(key) != null;
3535
}
3636
public Boolean getBoolean(String key) {
3737
String bval = get(key);

0 commit comments

Comments
 (0)