我想从历史数据初始化/更新模式的状态,并且在某些情况下经常得到StackOverflowError。我写了一个简单的例子来证明:
public class Main {
EsperPatternStackOverflow.zip
public static void main(String[] args) {
Configuration configuration = new Configuration();
configuration.addEventType("TestEvent", TestEvent.class);
configuration.getEngineDefaults().getViewResources().setShareViews(false);
configuration.getEngineDefaults().getExecution().setAllowIsolatedService(true);
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
epService.initialize();
EPServiceProviderIsolated isolatedService = epService.getEPServiceIsolated("Isolated");
EPStatement stmt = isolatedService.getEPAdministrator().createEPL("select * from pattern [every (a=TestEvent -> b=TestEvent(theString=a.theString)) where timer:within(1 day)]", "TestStatement",null);
int hour_ms = 60*60*1000;
isolatedService.getEPRuntime().sendEvent(new CurrentTimeEvent(System.currentTimeMillis()- 2*hour_ms));
isolatedService.getEPRuntime().sendEvent(new TestEvent("str1", 1));
stmt.addListener((newEvents, oldEvents) -> {
System.out.println("Fired");
});
isolatedService.getEPAdministrator().removeStatement(stmt);
epService.getEPRuntime().sendEvent(new TestEvent("str1", 3));
}
}
TestEvent是一个带有两个字段的简单类:int theInt,String theString。
结果:
Exception in thread "main" java.lang.StackOverflowError
at com.espertech.esper.filter.FilterParamIndexEquals.matchEvent(FilterParamIndexEquals.java:29)
at com.espertech.esper.filter.FilterHandleSetNode.matchEvent(FilterHandleSetNode.java:99)
at com.espertech.esper.filter.EventTypeIndex.matchType(EventTypeIndex.java:170)
at com.espertech.esper.filter.EventTypeIndex.matchEvent(EventTypeIndex.java:108)
at com.espertech.esper.filter.FilterServiceBase.retryableMatchEvent(FilterServiceBase.java:179)
at com.espertech.esper.filter.FilterServiceBase.evaluateInternal(FilterServiceBase.java:109)
at com.espertech.esper.filter.FilterServiceLockCoarse.evaluate(FilterServiceLockCoarse.java:67)
at com.espertech.esper.core.service.EPRuntimeImpl.handleFilterFault(EPRuntimeImpl.java:1267)
at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterSingle(EPRuntimeImpl.java:1242)
at com.espertech.esper.core.service.EPRuntimeImpl.handleFilterFault(EPRuntimeImpl.java:1271)
at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterSingle(EPRuntimeImpl.java:1242)
.......................................................................................................................................................................
此外,我得到了类似案例的下一个例外(仅在例外的顶点不同):
java.lang.StackOverflowError
at com.espertech.esper.event.bean.CGLibPropertyGetter.get(CGLibPropertyGetter.java:63)
at com.espertech.esper.filter.FilterParamIndexEquals.matchEvent(FilterParamIndexEquals.java:29)
at com.espertech.esper.filter.FilterHandleSetNode.matchEvent(FilterHandleSetNode.java:99)
at com.espertech.esper.filter.EventTypeIndex.matchType(EventTypeIndex.java:170)
at com.espertech.esper.filter.EventTypeIndex.matchEvent(EventTypeIndex.java:108)
at com.espertech.esper.filter.FilterServiceBase.retryableMatchEvent(FilterServiceBase.java:179)
at com.espertech.esper.filter.FilterServiceBase.evaluateInternal(FilterServiceBase.java:109)
at com.espertech.esper.filter.FilterServiceLockCoarse.evaluate(FilterServiceLockCoarse.java:67)
at com.espertech.esper.core.service.EPRuntimeImpl.handleFilterFault(EPRuntimeImpl.java:1267)
at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterSingle(EPRuntimeImpl.java:1242)
at com.espertech.esper.core.service.EPRuntimeImpl.handleFilterFault(EPRuntimeImpl.java:1271)
at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterSingle(EPRuntimeImpl.java:1242)
......................................................................................................................................................................
为什么会抛出此异常,如何解决此问题? 谢谢。
答案 0 :(得分:0)
已在5.5.0版本中修复
来自changelog(https://github.com/espertechinc/esper/blob/master/changelog.txt):
错误修复 - 修正了ESC-000-00001堆栈溢出问题创建隔离模式语句,部分完成模式和取消隔离stmt