我正在编写一个Android应用程序并遇到一个非常奇怪的错误,我无法解决这个问题。在变量"结果"下面的代码中根据不同的条件填充值。然后它应该返回。在调试器中,可以看到结果的值已正确设置。但是当到达return语句时(此时结果根据调试器具有正确的值),该方法确实返回null而不是result中的值。我也尝试清理项目并在另一台机器上编译具有相同结果的代码。我无法想象这里出了什么问题,但在我看来,在编译过程中出现了问题。
我在Windows 10计算机上使用64位jdk1.7.0_79并在带有Android Studio版本1.3.1的Nexus 7(2012)仿真器上运行代码
非常感谢您的帮助。
private static WikiItemContainer getMappingForIntermediateThrowEvent(IntermediateThrowEvent intermediateThrowEvent, List<WikiItemContainer> eventContainers) {
WikiItemContainer result = null;
List<EventDefinition> eventDefinitions = intermediateThrowEvent.getEventDefinitions();
if (eventDefinitions.isEmpty()) {
result = new WikiItemContainer(eventContainers.get(0).getItems().get(1));
} else if (eventDefinitions.size() > 1) {
result = new WikiItemContainer(eventContainers.get(10).getItems().get(6));
} else {
EventDefinition definition = eventDefinitions.get(0);
if (definition instanceof MessageEventDefinition) {
result = new WikiItemContainer(eventContainers.get(1).getItems().get(6));
} else if (definition instanceof EscalationEventDefinition) {
result = new WikiItemContainer(eventContainers.get(3).getItems().get(4));
} else if (definition instanceof LinkEventDefinition) {
result = new WikiItemContainer(eventContainers.get(5).getItems().get(1));
} else if (definition instanceof CompensateEventDefinition) {
result = new WikiItemContainer(eventContainers.get(8).getItems().get(2));
} else if (definition instanceof SignalEventDefinition) {
result = new WikiItemContainer(eventContainers.get(9).getItems().get(6));
}
}
return result;
}
答案 0 :(得分:1)
result
为空的条件有一个:
private static WikiItemContainer getMappingForIntermediateThrowEvent(IntermediateThrowEvent intermediateThrowEvent, List<WikiItemContainer> eventContainers) {
WikiItemContainer result = null;
List<EventDefinition> eventDefinitions = intermediateThrowEvent.getEventDefinitions();
if (eventDefinitions.isEmpty()) {
result = new WikiItemContainer(eventContainers.get(0).getItems().get(1));
} else if (eventDefinitions.size() > 1) {
result = new WikiItemContainer(eventContainers.get(10).getItems().get(6));
} else {
EventDefinition definition = eventDefinitions.get(0);
if (definition instanceof MessageEventDefinition) {
result = new WikiItemContainer(eventContainers.get(1).getItems().get(6));
} else if (definition instanceof EscalationEventDefinition) {
result = new WikiItemContainer(eventContainers.get(3).getItems().get(4));
} else if (definition instanceof LinkEventDefinition) {
result = new WikiItemContainer(eventContainers.get(5).getItems().get(1));
} else if (definition instanceof CompensateEventDefinition) {
result = new WikiItemContainer(eventContainers.get(8).getItems().get(2));
} else if (definition instanceof SignalEventDefinition) {
result = new WikiItemContainer(eventContainers.get(9).getItems().get(6));
}
// What value will result have here if none of the if statements above are entered?
}
return result;
}
答案 1 :(得分:0)
您是否尝试过记录定义? 尝试
too many connections
并记录eventDefinition列表的大小
Log.v("xxxx","definition:."+definition.getClass().Name());