From c4ee8f5997a6d2006b6a39116d1cc6d857585e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pet=C5=99=C3=AD=C4=8Dek?= Date: Tue, 29 Jun 2021 16:34:54 +0200 Subject: [PATCH] Fix model loading from stream 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 4a84f29afd00..e6ef07d6cbc7 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 static Booster loadModel(InputStream in) throws XGBoostError, IOException os.write(buf, 0, size); } in.close(); - return Booster.loadModel(buf); + return Booster.loadModel(os.toByteArray()); } /**