From 46c46829ce9e2aaf5acfed7278ac16f95a6b0bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pet=C5=99=C3=AD=C4=8Dek?= Date: Sun, 15 Aug 2021 15:04:33 +0200 Subject: [PATCH] Fix model loading from stream (#7067) Fix bug introduced in 17913713b554d820a8ce94226d854b4a5f1d8bbc (allow loading from byte array) When loading model from stream, only last buffer read from the input stream is used to construct the model. This may work for models smaller than 1 MiB (if you are lucky enough to read the whole model at once), but will always fail if the model is larger. --- .../xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java index b2d0624c2..36ef18dbf 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java @@ -61,7 +61,7 @@ public class XGBoost { os.write(buf, 0, size); } in.close(); - return Booster.loadModel(buf); + return Booster.loadModel(os.toByteArray()); } /**