Skip to content

Commit 810a224

Browse files
ScrapCodesJoshRosen
authored andcommitted
[SPARK-3433][BUILD] Fix for Mima false-positives with @DeveloperAPI and @experimental annotations.
Actually false positive reported was due to mima generator not picking up the new jars in presence of old jars(theoretically this should not have happened.). So as a workaround, ran them both separately and just append them together. Author: Prashant Sharma <[email protected]> Author: Prashant Sharma <[email protected]> Closes #2285 from ScrapCodes/mima-fix and squashes the following commits: 093c76f [Prashant Sharma] Update mima 59012a8 [Prashant Sharma] Update mima 35b6c71 [Prashant Sharma] SPARK-3433 Fix for Mima false-positives with @DeveloperAPI and @experimental annotations. (cherry picked from commit ecf0c02) Signed-off-by: Josh Rosen <[email protected]> Conflicts: project/MimaExcludes.scala
1 parent c98dc0e commit 810a224

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

dev/mima

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ FWDIR="$(cd `dirname $0`/..; pwd)"
2525
cd "$FWDIR"
2626

2727
echo -e "q\n" | sbt/sbt oldDeps/update
28+
rm -f .generated-mima*
29+
30+
# Generate Mima Ignore is called twice, first with latest built jars
31+
# on the classpath and then again with previous version jars on the classpath.
32+
# Because of a bug in GenerateMIMAIgnore that when old jars are ahead on classpath
33+
# it did not process the new classes (which are in assembly jar).
34+
./bin/spark-class org.apache.spark.tools.GenerateMIMAIgnore
2835

2936
export SPARK_CLASSPATH=`find lib_managed \( -name '*spark*jar' -a -type f \) | tr "\\n" ":"`
3037
echo "SPARK_CLASSPATH=$SPARK_CLASSPATH"
3138

3239
./bin/spark-class org.apache.spark.tools.GenerateMIMAIgnore
40+
3341
echo -e "q\n" | sbt/sbt mima-report-binary-issues | grep -v -e "info.*Resolving"
3442
ret_val=$?
3543

project/MimaBuild.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ object MimaBuild {
3030

3131
def excludeMember(fullName: String) = Seq(
3232
ProblemFilters.exclude[MissingMethodProblem](fullName),
33+
// Sometimes excluded methods have default arguments and
34+
// they are translated into public methods/fields($default$) in generated
35+
// bytecode. It is not possible to exhustively list everything.
36+
// But this should be okay.
37+
ProblemFilters.exclude[MissingMethodProblem](fullName+"$default$2"),
38+
ProblemFilters.exclude[MissingMethodProblem](fullName+"$default$1"),
3339
ProblemFilters.exclude[MissingFieldProblem](fullName),
3440
ProblemFilters.exclude[IncompatibleResultTypeProblem](fullName),
3541
ProblemFilters.exclude[IncompatibleMethTypeProblem](fullName),

project/SparkBuild.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ object OldDeps {
187187
Some("org.apache.spark" % fullId % "1.0.0")
188188
}
189189

190-
def oldDepsSettings() = Defaults.defaultSettings ++ Seq(
190+
def oldDepsSettings() = Defaults.coreDefaultSettings ++ Seq(
191191
name := "old-deps",
192192
scalaVersion := "2.10.4",
193193
retrieveManaged := true,

tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import scala.collection.mutable
2424
import scala.collection.JavaConversions._
2525
import scala.reflect.runtime.universe.runtimeMirror
2626
import scala.reflect.runtime.{universe => unv}
27+
import scala.util.Try
2728

2829
/**
2930
* A tool for generating classes to be excluded during binary checking with MIMA. It is expected
@@ -121,12 +122,17 @@ object GenerateMIMAIgnore {
121122
}
122123

123124
def main(args: Array[String]) {
125+
import scala.tools.nsc.io.File
124126
val (privateClasses, privateMembers) = privateWithin("org.apache.spark")
125-
scala.tools.nsc.io.File(".generated-mima-class-excludes").
126-
writeAll(privateClasses.mkString("\n"))
127+
val previousContents = Try(File(".generated-mima-class-excludes").lines()).
128+
getOrElse(Iterator.empty).mkString("\n")
129+
File(".generated-mima-class-excludes")
130+
.writeAll(previousContents + privateClasses.mkString("\n"))
127131
println("Created : .generated-mima-class-excludes in current directory.")
128-
scala.tools.nsc.io.File(".generated-mima-member-excludes").
129-
writeAll(privateMembers.mkString("\n"))
132+
val previousMembersContents = Try(File(".generated-mima-member-excludes").lines)
133+
.getOrElse(Iterator.empty).mkString("\n")
134+
File(".generated-mima-member-excludes").writeAll(previousMembersContents +
135+
privateMembers.mkString("\n"))
130136
println("Created : .generated-mima-member-excludes in current directory.")
131137
}
132138

0 commit comments

Comments
 (0)