Skip to content

Commit f45558d

Browse files
committed
Merge branch 'release/0.7.2'
2 parents 109f39b + 70ad982 commit f45558d

File tree

11 files changed

+462
-221
lines changed

11 files changed

+462
-221
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ sudo: false
33
scala:
44
- 2.10.5
55
- 2.11.7
6+
jdk:
7+
- openjdk6
8+
- oraclejdk7
9+
- oraclejdk8

CHANGES.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# chill #
22

3+
### 0.7.2 ###
4+
* Setting the class loader by default: https://github.com/twitter/chill/pull/242
5+
6+
### 0.7.1 ###
7+
* Add testing support for Java 6, 7 and 8.
8+
* Adds two Injection's to lift T into an Externalizer of T.
9+
* Protobuf module is Java only.
10+
311
### 0.7.0 ###
412
* Adds Scrooge 2.11 support now that the artifact is out, sets up for c…: https://github.com/twitter/chill/pull/236
513
* make chill 1.6 compatible: https://github.com/twitter/chill/pull/231

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Discussion occurs primarily on the [Chill mailing list](https://groups.google.co
159159

160160
## Maven
161161

162-
Chill modules are available on Maven Central. The current groupid and version for all modules is, respectively, `"com.twitter"` and `0.6.0` and each scala project is published for `2.10` and `2.11`. Search [search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cchill) when in doubt.
162+
Chill modules are available on Maven Central. The current groupid and version for all modules is, respectively, `"com.twitter"` and `0.7.2` and each scala project is published for `2.10` and `2.11`. Search [search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cchill) when in doubt.
163163

164164
## Authors
165165

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2012 Twitter, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package com.twitter.chill
18+
19+
import _root_.java.io.{
20+
ByteArrayOutputStream,
21+
ByteArrayInputStream,
22+
ObjectInputStream,
23+
ObjectOutputStream
24+
}
25+
26+
import com.twitter.bijection.Injection
27+
import scala.util.Try
28+
29+
/**
30+
* A Injection to serialize an externalizer to bytes
31+
*
32+
* This method isn't safe since calling get on an Externalizer[T] could still throw despite the inversion
33+
* here having worked as advertized. Since it is at the point of the get we unpack the inner box.
34+
*/
35+
object ExternalizerCodec {
36+
implicit def apply[T]: ExternalizerCodec[T] = new ExternalizerCodec[T]
37+
}
38+
39+
class ExternalizerCodec[T] extends Injection[Externalizer[T], Array[Byte]] {
40+
def apply(extern: Externalizer[T]): Array[Byte] = {
41+
val baos = new ByteArrayOutputStream()
42+
val oos = new ObjectOutputStream(baos)
43+
oos.writeObject(extern)
44+
baos.toByteArray
45+
}
46+
def invert(bytes: Array[Byte]): Try[Externalizer[T]] = Try {
47+
val testInput = new ByteArrayInputStream(bytes)
48+
val ois = new ObjectInputStream(testInput)
49+
ois.readObject.asInstanceOf[Externalizer[T]] // this may throw
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2012 Twitter, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package com.twitter.chill
18+
19+
import _root_.java.io.{
20+
ByteArrayOutputStream,
21+
ByteArrayInputStream,
22+
ObjectInputStream,
23+
ObjectOutputStream
24+
}
25+
26+
import com.twitter.bijection.Injection
27+
import scala.util.Try
28+
29+
/**
30+
* An Injection to lift a type T into an Externalizer
31+
*/
32+
object ExternalizerInjection {
33+
implicit def builder[T]: ExternalizerInjection[T] = apply[T]
34+
35+
def apply[T]: ExternalizerInjection[T] = new ExternalizerInjection[T]
36+
}
37+
38+
class ExternalizerInjection[T] extends Injection[T, Externalizer[T]] {
39+
def apply(t: T): Externalizer[T] = {
40+
Externalizer(t)
41+
}
42+
def invert(extern: Externalizer[T]): Try[T] = Try {
43+
extern.get
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright 2012 Twitter, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package com.twitter.chill
18+
19+
import org.scalatest._
20+
21+
import com.twitter.bijection.Injection
22+
import scala.util.Try
23+
24+
class NotSerializable {
25+
val x = "abcd"
26+
override def equals(other: Any): Boolean =
27+
other match {
28+
case i: NotSerializable => true
29+
case _ => false
30+
}
31+
}
32+
class ExternalizerCodecSpec extends WordSpec {
33+
import ExternalizerCodec._
34+
import ExternalizerInjection._
35+
36+
def rt[T: ExternalizerInjection: ExternalizerCodec](t: T): Try[T] = {
37+
val connectedInj = Injection.connect[T, Externalizer[T], Array[Byte]]
38+
connectedInj.invert(connectedInj(t))
39+
}
40+
41+
"The codec on Externalizer" should {
42+
"round trip objects" in {
43+
val x = rt(() => Foo.Bar).get
44+
assert(x() == Foo.Bar)
45+
}
46+
"round not serializable classes" in {
47+
val baseSerializable = new NotSerializable
48+
val x = rt(baseSerializable).get
49+
assert(x == baseSerializable, "Should be value equal")
50+
assert(x ne baseSerializable, "Should not be reference equal, since through a serializer")
51+
}
52+
53+
}
54+
}
55+

chill-scala/src/main/scala/com/twitter/chill/ScalaKryoInstantiator.scala

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class EmptyScalaKryoInstantiator extends KryoInstantiator {
5757
val k = new KryoBase
5858
k.setRegistrationRequired(false)
5959
k.setInstantiatorStrategy(new org.objenesis.strategy.StdInstantiatorStrategy)
60+
61+
// Handle cases where we may have an odd classloader setup like with libjars
62+
// for hadoop
63+
val classLoader = Thread.currentThread.getContextClassLoader
64+
k.setClassLoader(classLoader)
65+
6066
k
6167
}
6268
}

project/Build.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ object ChillBuild extends Build {
119119
* with the current.
120120
*/
121121
val unreleasedModules = Set[String]("akka")
122-
val javaOnly = Set[String]("storm", "java", "hadoop", "thrift")
122+
val javaOnly = Set[String]("storm", "java", "hadoop", "thrift", "protobuf")
123123

124124
def youngestForwardCompatible(subProj: String) =
125125
Some(subProj)
126126
.filterNot(unreleasedModules.contains(_))
127127
.map { s =>
128128
val suffix = if (javaOnly.contains(s)) "" else "_2.10"
129-
"com.twitter" % ("chill-" + s + suffix) % "0.6.0"
129+
"com.twitter" % ("chill-" + s + suffix) % "0.7.1"
130130
}
131131

132132
def module(name: String) = {
@@ -136,7 +136,7 @@ object ChillBuild extends Build {
136136
previousArtifact := youngestForwardCompatible(name),
137137
// Disable cross publishing for java artifacts
138138
publishArtifact <<= (scalaVersion) { scalaVersion =>
139-
if(javaOnly.contains(name) && scalaVersion.startsWith("2.10")) false else true
139+
if(javaOnly.contains(name) && scalaVersion.startsWith("2.11")) false else true
140140
}
141141
)
142142
)

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.8
1+
sbt.version=0.13.9

0 commit comments

Comments
 (0)