美好的一天,
以下是我java.util.ArrayList
中的代码:
@Override
public boolean addAll(Collection<? extends E> collection) {
int localLastIndex = lastIndex;
Object[] dumpArray = collection.toArray();
if (dumpArray.length == 0) { /this is line 244
return false;
}
if (dumpArray.length > array.length - localLastIndex) { //this is line 247
localLastIndex = growAtEnd(dumpArray.length, localLastIndex);
}
System.arraycopy(dumpArray, 0, this.array, localLastIndex,
dumpArray.length);
localLastIndex += dumpArray.length;
modCount++;
lastIndex = localLastIndex;
return true;
}
这是我的错误日志:我得到空指针异常。
java.lang.NullPointerException: null
at java.util.ArrayList.addAll(ArrayList.java:247) ~[na:na]
在第247行,我相信dumpArray
不会为null,如果它为null,那么它将在第244行早期命中空指针异常,因为该行已使用dumpArray
。
如果dumpArray为null,为什么addAll()会在第247行引发异常,如果它可能先前抛出异常?也就是说,如果dumpArray为null,则不应该
if (dumpArray.length == 0) { /this is line 244
已经抛出了异常?
这是我的代码:
List< FixedDepositReceiptDetail > receipts = new ArrayList< FixedDepositReceiptDetail >( );
while ( response.isMoreRecords( ) ) {
receipts.addAll( response.getReceipts( ) );
}
这是我的完整堆栈跟踪:
java.lang.NullPointerException: null
at java.util.ArrayList.addAll(ArrayList.java:247) ~[na:na]
at com.cv.ibs.cib.eai.impl.AccountQueryServiceImpl.getFixedDepositDetail(AccountQueryServiceImpl.java:239) ~[com.cv.ibs.cib.jar:na]
at com.cv.ibs.cib.eai.impl.AccountQueryServiceImpl.getAccountDetail(AccountQueryServiceImpl.java:158) ~[com.cv.ibs.cib.jar:na]
at com.cv.ibs.cib.app.account.command.AccountDetailsCommandHandler.execute(AccountDetailsCommandHandler.java:57) ~[com.cv.ibs.cib.jar:na]
at com.cv.ibs.cib.app.account.command.AccountDetailsCommandHandler.execute(AccountDetailsCommandHandler.java:1) ~[com.cv.ibs.cib.jar:na]
at com.cv.common.command.CommandExecutor.doExecute(CommandExecutor.java:50) ~[com.cv.common.jar:na]
at com.cv.common.command.CommandExecutor.execute(CommandExecutor.java:44) ~[com.cv.common.jar:na]
at com.cv.common.command.LocalCommandHandler.execute(LocalCommandHandler.java:46) ~[com.cv.common.jar:na]
at com.cv.common.command.LocalCommandHandler.execute(LocalCommandHandler.java:1) ~[com.cv.common.jar:na]
at com.cv.common.command.CommandTemplate.execute(CommandTemplate.java:33) ~[com.cv.common.jar:na]
at com.cv.ibs.cib.app.account.ui.AbstractAccountAction.detail(AbstractAccountAction.java:408) ~[com.cv.ibs.cib.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) ~[na:1.6.0]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) ~[na:1.6.0]
at java.lang.reflect.Method.invoke(Method.java:611) ~[na:1.6.0]
at net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158) ~[stripes-1.5_cv.jar:955]
at com.cv.ibs.cib.common.ui.interceptor.JSTokenInterceptor.intercept(JSTokenInterceptor.java:60) ~[com.cv.ibs.cib.common.jar:na]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at org.stripesstuff.plugin.session.SessionStoreInterceptor.intercept(SessionStoreInterceptor.java:52) ~[stripesstuff-0.1.jar:74M]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at com.cv.ibs.cib.audit.ui.interceptor.BaseAuditLogInterceptor.intercept(BaseAuditLogInterceptor.java:109) ~[com.cv.ibs.cib.jar:na]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at com.cv.ibs.cib.audit.ui.interceptor.BaseAuditLogInterceptor.intercept(BaseAuditLogInterceptor.java:109) ~[com.cv.ibs.cib.jar:na]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at com.cv.ibs.cib.audit.ui.interceptor.BaseAuditLogInterceptor.intercept(BaseAuditLogInterceptor.java:109) ~[com.cv.ibs.cib.jar:na]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at com.cv.ibs.cib.common.ui.interceptor.TokenInterceptor.intercept(TokenInterceptor.java:122) ~[com.cv.ibs.cib.common.jar:na]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:285) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.DispatcherServlet.doPost(DispatcherServlet.java:167) ~[stripes-1.5_cv.jar:955]
at net.sourceforge.stripes.controller.DispatcherServlet.doGet(DispatcherServlet.java:67) ~[stripes-1.5_cv.jar:955]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) ~[javax.j2ee.servlet.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) ~[javax.j2ee.servlet.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) [com.ibm.ws.webcontainer.jar:na]
at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:246) ~[stripes-1.5_cv.jar:955]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:246) ~[stripes-1.5_cv.jar:955]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) [sitemesh-2.4.2.jar:na]
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) [sitemesh-2.4.2.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:399) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at com.cv.ibs.cib.common.security.filter.AOBAuthenticationProcessFilter.doFilterHttp(AOBAuthenticationProcessFilter.java:99) [com.cv.ibs.cib.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at com.cv.ibs.cib.common.security.context.SecurityContextDetailsFilter.doFilterHttp(SecurityContextDetailsFilter.java:44) [com.cv.ibs.cib.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:411) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:188) [spring-security-core-2.0.7.RELEASE.jar:na]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) [org.springframework.web-3.0.4.RELEASE.jar:3.0.4.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) [org.springframework.web-3.0.4.RELEASE.jar:3.0.4.RELEASE]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.cv.ibs.cib.common.ui.filter.MetaContextFactoryFilter.doFilter(MetaContextFactoryFilter.java:61) [com.cv.ibs.cib.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) [displaytag-1.2.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.cv.common.web.filter.NoCacheFilter.doFilter(NoCacheFilter.java:65) [com.cv.common.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.cv.common.web.filter.NoCacheFilter.doFilter(NoCacheFilter.java:65) [com.cv.common.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.cv.ibs.cib.common.ui.filter.MDCInfoCaptureFilter.doFilter(MDCInfoCaptureFilter.java:92) [com.cv.ibs.cib.common.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.cv.ibs.cib.common.ui.filter.MDCInfoCaptureFilter.doFilter(MDCInfoCaptureFilter.java:92) [com.cv.ibs.cib.common.jar:na]
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) ~[com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:960) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1064) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:914) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:461) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:528) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:314) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) [com.ibm.ws.runtime.jar:na]
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) [com.ibm.ws.runtime.jar:na]
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) [com.ibm.ws.runtime.jar:na]
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) [com.ibm.ws.runtime.jar:na]
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) [com.ibm.ws.runtime.jar:na]
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) [com.ibm.ws.runtime.jar:na]
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1864) [com.ibm.ws.runtime.jar:na]
请告知。