Skip to content

Commit 0922b64

Browse files
committed
Add RunApp.start(packageName) API; minor code update in ParamTree; fix issue in CollectionLoader when NumberFormatException encountered;
1 parent b3748d6 commit 0922b64

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/main/java/act/boot/app/RunApp.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public static void start(Class<?> anyController) throws Exception {
2727
start(null, null, anyController);
2828
}
2929

30+
public static void start(String packageName) throws Exception {
31+
start(null, null, packageName);
32+
}
33+
3034
public static void start(String appName, String appVersion, Class<?> anyController) throws Exception {
3135
String pkg = anyController.getPackage().getName();
3236
start(appName, appVersion, pkg);

src/main/java/act/inject/param/CollectionLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Object load(Object bean, ActContext<?> context, boolean noDefaultValue) {
8989
try {
9090
id = Integer.parseInt(s);
9191
} catch (NumberFormatException e) {
92-
throw new BadRequest("cannot parse param: list index[%s] is not a number: %s", s);
92+
throw new BadRequest("cannot parse param: list index is not a number: %s", s);
9393
}
9494
ParamTreeNode child = node.child(s);
9595
if (child.isLeaf()) {

src/main/java/act/inject/param/ParamTree.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
package act.inject.param;
22

33
import act.util.ActContext;
4+
import org.osgl.logging.LogManager;
5+
import org.osgl.logging.Logger;
46
import org.rythmengine.utils.S;
57

68
import java.util.*;
79

810
class ParamTree {
911

12+
private static final Logger LOGGER = LogManager.get(ParamTree.class);
13+
1014
private Map<ParamKey, ParamTreeNode> allNodes = new HashMap<ParamKey, ParamTreeNode>();
1115

1216
void build(ActContext context) {
1317
Set<String> paramKeys = context.paramKeys();
1418
for (String key : paramKeys) {
1519
String[] vals = context.paramVals(key);
16-
buildNode(key, vals, context);
20+
buildNode(key, vals);
1721
}
1822
}
1923

20-
private void buildNode(String rawKey, String[] vals, ActContext<?> context) {
24+
private void buildNode(String rawKey, String[] vals) {
2125
ParamKey key = ParamKey.of(parseRawParamKey(rawKey));
2226
ParamTreeNode node;
2327
int len = vals.length;
@@ -106,6 +110,8 @@ private static void addTokenToList(List<String> list, StringBuilder token) {
106110
String s = token.toString();
107111
if (S.notEmpty(s)) {
108112
list.add(s);
113+
} else {
114+
LOGGER.warn("empty index encountered");
109115
}
110116
token.delete(0, s.length() + 1);
111117
}

0 commit comments

Comments
 (0)