Skip to content

Commit 911de38

Browse files
committed
Merge pull request #204 from tsdeng/fix_kryo_set_conf
fix setConf
2 parents 33da29c + b86a794 commit 911de38

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

chill-avro/src/main/scala/com/twitter/chill/avro/AvroSerializer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ limitations under the License.
1515
package com.twitter.chill.avro
1616

1717
import com.twitter.bijection.Injection
18-
import com.twitter.bijection.avro.{GenericAvroCodecs, SpecificAvroCodecs}
19-
import com.twitter.chill.{InjectiveSerializer, KSerializer}
18+
import com.twitter.bijection.avro.{ GenericAvroCodecs, SpecificAvroCodecs }
19+
import com.twitter.chill.{ InjectiveSerializer, KSerializer }
2020
import org.apache.avro.Schema
2121
import org.apache.avro.generic.GenericRecord
2222
import org.apache.avro.specific.SpecificRecordBase

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**

0 commit comments

Comments
 (0)