[jvm-packages] Add back the overriden finalize() method for SBooster (#3011)

* Convert SIGSEGV to XGBoostError

* Address CR Comments

* Address CR Comments
This commit is contained in:
Yun Ni 2018-01-06 14:07:37 -08:00 committed by Nan Zhu
parent 65fb4e3f5c
commit 740eba42f7

View File

@ -23,6 +23,12 @@ import ml.dmlc.xgboost4j.java.XGBoostError
import scala.collection.JavaConverters._
import scala.collection.mutable
/**
* Booster for xgboost, this is a model API that support interactive build of a XGBoost Model
*
* DEVELOPER WARNING: A Java Booster must not be shared by more than one Scala Booster
* @param booster the java booster object.
*/
class Booster private[xgboost4j](private[xgboost4j] var booster: JBooster)
extends Serializable with KryoSerializable {
@ -202,6 +208,11 @@ class Booster private[xgboost4j](private[xgboost4j] var booster: JBooster)
booster.dispose()
}
override def finalize(): Unit = {
super.finalize()
dispose
}
override def write(kryo: Kryo, output: Output): Unit = {
kryo.writeObject(output, booster)
}