aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarcelo Vanzin <vanzin@cloudera.com>2014-09-23 13:42:00 -0700
committerPatrick Wendell <pwendell@gmail.com>2014-09-23 13:42:00 -0700
commit8dfe79ffb204807945e3c09b75c7255b09ad2a97 (patch)
tree3d046d43ff09a4ac4fbde8855fcce29cbfa73418 /core
parenta08153f8a3e7bad81bae330ec4152651da5e7804 (diff)
downloadspark-8dfe79ffb204807945e3c09b75c7255b09ad2a97.tar.gz
spark-8dfe79ffb204807945e3c09b75c7255b09ad2a97.tar.bz2
spark-8dfe79ffb204807945e3c09b75c7255b09ad2a97.zip
[SPARK-3647] Add more exceptions to Guava relocation.
Guava's Optional refers to some package private classes / methods, and when those are relocated the code stops working, throwing exceptions. So add the affected classes to the exception list too, and add a unit test. (Note that this unit test only really makes sense in maven, since we don't relocate in the sbt build. Also, JavaAPISuite doesn't seem to be run by "mvn test" - I had to manually add command line options to enable it.) Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #2496 from vanzin/SPARK-3647 and squashes the following commits: 84f58d7 [Marcelo Vanzin] [SPARK-3647] Add more exceptions to Guava relocation.
Diffstat (limited to 'core')
-rw-r--r--core/pom.xml2
-rw-r--r--core/src/test/java/org/apache/spark/JavaAPISuite.java26
2 files changed, 28 insertions, 0 deletions
diff --git a/core/pom.xml b/core/pom.xml
index 2a81f6df28..e012c5e673 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -343,7 +343,9 @@
<filter>
<artifact>com.google.guava:guava</artifact>
<includes>
+ <include>com/google/common/base/Absent*</include>
<include>com/google/common/base/Optional*</include>
+ <include>com/google/common/base/Present*</include>
</includes>
</filter>
</filters>
diff --git a/core/src/test/java/org/apache/spark/JavaAPISuite.java b/core/src/test/java/org/apache/spark/JavaAPISuite.java
index b8574dfb42..b8c23d524e 100644
--- a/core/src/test/java/org/apache/spark/JavaAPISuite.java
+++ b/core/src/test/java/org/apache/spark/JavaAPISuite.java
@@ -1307,4 +1307,30 @@ public class JavaAPISuite implements Serializable {
SomeCustomClass[] collected = (SomeCustomClass[]) rdd.rdd().retag(SomeCustomClass.class).collect();
Assert.assertEquals(data.size(), collected.length);
}
+
+ /**
+ * Test for SPARK-3647. This test needs to use the maven-built assembly to trigger the issue,
+ * since that's the only artifact where Guava classes have been relocated.
+ */
+ @Test
+ public void testGuavaOptional() {
+ // Stop the context created in setUp() and start a local-cluster one, to force usage of the
+ // assembly.
+ sc.stop();
+ JavaSparkContext localCluster = new JavaSparkContext("local-cluster[1,1,512]", "JavaAPISuite");
+ try {
+ JavaRDD<Integer> rdd1 = localCluster.parallelize(Arrays.asList(1, 2, null), 3);
+ JavaRDD<Optional<Integer>> rdd2 = rdd1.map(
+ new Function<Integer, Optional<Integer>>() {
+ @Override
+ public Optional<Integer> call(Integer i) {
+ return Optional.fromNullable(i);
+ }
+ });
+ rdd2.collect();
+ } finally {
+ localCluster.stop();
+ }
+ }
+
}