diff options
author | Marcelo Vanzin <vanzin@cloudera.com> | 2014-09-23 13:42:00 -0700 |
---|---|---|
committer | Patrick Wendell <pwendell@gmail.com> | 2014-09-23 13:42:00 -0700 |
commit | 8dfe79ffb204807945e3c09b75c7255b09ad2a97 (patch) | |
tree | 3d046d43ff09a4ac4fbde8855fcce29cbfa73418 /core/src | |
parent | a08153f8a3e7bad81bae330ec4152651da5e7804 (diff) | |
download | spark-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/src')
-rw-r--r-- | core/src/test/java/org/apache/spark/JavaAPISuite.java | 26 |
1 files changed, 26 insertions, 0 deletions
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(); + } + } + } |