From e99ab0d1dd2b5c860d315b9ddf7a8a59567fd630 Mon Sep 17 00:00:00 2001 From: yanqingmen Date: Mon, 6 Jul 2015 20:56:17 +0800 Subject: [PATCH] minor fix --- .../xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java | 6 ++++-- .../xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java index 0f296241b..4d34f43c6 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java @@ -76,14 +76,16 @@ public final class Booster { * @throws org.dmlc.xgboost4j.util.XgboostError */ public Booster(Iterable> params, String modelPath) throws XgboostError { - long[] out = new long[1]; init(null); + if(modelPath == null) { + throw new NullPointerException("modelPath : null"); + } loadModel(modelPath); setParam("seed","0"); setParams(params); } - + private void init(DMatrix[] dMatrixs) throws XgboostError { diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java index b056cad09..6beae9c90 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java @@ -55,6 +55,9 @@ public class DMatrix { * @throws org.dmlc.xgboost4j.util.XgboostError */ public DMatrix(String dataPath) throws XgboostError { + if(dataPath == null) { + throw new NullPointerException("dataPath: null"); + } long[] out = new long[1]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromFile(dataPath, 1, out)); handle = out[0];