@@ -136,7 +136,7 @@ public static JSONObject init(boolean shutdownWhenServerError, APIJSONCreator cr
136136
137137
138138 boolean isAll = table == null || table .isEmpty ();
139-
139+
140140 JSONObject function = isAll ? new JSONRequest () : table ;
141141 JSONRequest functionItem = new JSONRequest ();
142142 functionItem .put (FUNCTION_ , function );
@@ -156,9 +156,12 @@ public static JSONObject init(boolean shutdownWhenServerError, APIJSONCreator cr
156156 Log .w (TAG , "init isAll && size <= 0,,没有可用的远程函数" );
157157 throw new NullPointerException ("没有可用的远程函数" );
158158 }
159-
160159
161- Map <String , JSONObject > newMap = new LinkedHashMap <>();
160+
161+ if (isAll ) { // 必须在测试 invoke 前把配置 put 进 FUNCTION_MAP!
162+ FUNCTION_MAP = new LinkedHashMap <>();
163+ }
164+ Map <String , JSONObject > newMap = FUNCTION_MAP ; // 必须在测试 invoke 前把配置 put 进 FUNCTION_MAP! new LinkedHashMap<>();
162165
163166 for (int i = 0 ; i < size ; i ++) {
164167 JSONObject item = list .getJSONObject (i );
@@ -177,7 +180,7 @@ public static JSONObject init(boolean shutdownWhenServerError, APIJSONCreator cr
177180 // demo.put(JSONRequest.KEY_TAG, item.getString(JSONRequest.KEY_TAG));
178181 // demo.put(JSONRequest.KEY_VERSION, item.getInteger(JSONRequest.KEY_VERSION));
179182
180- newMap .put (name , item ); //必须在测试 invoke 前!
183+ newMap .put (name , item ); // 必须在测试 invoke 前把配置 put 进 FUNCTION_MAP!
181184
182185 String [] methods = StringUtil .split (item .getString ("methods" ));
183186 JSONObject r = new APIJSONParser (
@@ -193,13 +196,14 @@ public static JSONObject init(boolean shutdownWhenServerError, APIJSONCreator cr
193196 }
194197
195198 }
196-
197- if (isAll ) {
198- FUNCTION_MAP = newMap ;
199- }
200- else {
201- FUNCTION_MAP .putAll (newMap );
202- }
199+
200+ // 必须在测试 invoke 前把配置 put 进 FUNCTION_MAP!
201+ // if (isAll) {
202+ // FUNCTION_MAP = newMap;
203+ // }
204+ // else {
205+ // FUNCTION_MAP.putAll(newMap);
206+ // }
203207
204208 return response ;
205209 }
@@ -249,12 +253,12 @@ public static void test(APIJSONFunctionParser function) throws Exception {
249253 }
250254
251255 // 等数据库 Function 表加上 plus 配置再过两个以上迭代(应该是到 5.0)后再取消注释
252- // Log.i(TAG, "plus(1,-2) = " + function.invoke("plus(i0,i1)", request));
253- // AssertUtil.assertEqual(-1, function.invoke("plus(i0,i1)", request));
254-
256+ // Log.i(TAG, "plus(1,-2) = " + function.invoke("plus(i0,i1)", request));
257+ // AssertUtil.assertEqual(-1, function.invoke("plus(i0,i1)", request));
258+
255259 Log .i (TAG , "count([1,2,4,10]) = " + function .invoke ("countArray(array)" , request ));
256260 AssertUtil .assertEqual (4 , function .invoke ("countArray(array)" , request ));
257-
261+
258262 Log .i (TAG , "isContain([1,2,4,10], 10) = " + function .invoke ("isContain(array,id)" , request ));
259263 AssertUtil .assertEqual (true , function .invoke ("isContain(array,id)" , request ));
260264
0 commit comments