We're updating the issue view to help you get more done. 

OAIDataProvider throws NPE if database is empty

Description

If I go to /servlets/OAIDataProvider having a fresh installed MIR without any documents, I get the following StackTrace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203) at java.util.Optional.<init>(Optional.java:96) at java.util.Optional.of(Optional.java:108) at org.mycore.datamodel.metadata.history.MCRMetadataHistoryManager.getHistoryStart(MCRMetadataHistoryManager.java:58) at org.mycore.oai.MCROAIDeletedSearcher.getEarliestTimestamp(MCROAIDeletedSearcher.java:91) at java.util.Optional.flatMap(Optional.java:241) at org.mycore.oai.MCROAICombinedSearcher.getEarliestTimestamp(MCROAICombinedSearcher.java:92) at org.mycore.oai.MCROAIIdentify.calculateEarliestTimestamp(MCROAIIdentify.java:131) at org.mycore.oai.MCROAIIdentify.<init>(MCROAIIdentify.java:70) at org.mycore.oai.MCROAIAdapter.getIdentify(MCROAIAdapter.java:139) at org.mycore.oai.MCROAIAdapter.getIdentify(MCROAIAdapter.java:56) at org.mycore.oai.pmh.dataprovider.jaxb.JAXBOAIProvider.handle(JAXBOAIProvider.java:52) at org.mycore.oai.pmh.dataprovider.jaxb.JAXBOAIProvider.handleRequest(JAXBOAIProvider.java:43) at org.mycore.oai.MCROAIDataProvider.doGetPost(MCROAIDataProvider.java:92) at org.mycore.frontend.servlets.MCRServlet.doGet(MCRServlet.java:170) at org.mycore.frontend.servlets.MCRServlet.render(MCRServlet.java:443) at org.mycore.frontend.servlets.MCRServlet.processRenderingPhase(MCRServlet.java:409) at org.mycore.frontend.servlets.MCRServlet.doGetPost(MCRServlet.java:304) at org.mycore.frontend.servlets.MCRServlet.doGet(MCRServlet.java:143) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.mycore.frontend.filter.MCRWebAppBaseFilter.doFilter(MCRWebAppBaseFilter.java:41) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.mycore.frontend.filter.MCRRequestAuthenticationFilter.doFilter(MCRRequestAuthenticationFilter.java:57) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.mycore.frontend.filter.MCRRequestDebugFilter.doFilter(MCRRequestDebugFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120) at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:479) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)

Environment

None

Status

Assignee

Thomas Scheffler

Reporter

Kathleen Neumann

Labels

None

External issue ID

None

External issue ID

None

External issue ID

None

URL

None

External issue ID

None

External issue ID

None

Components

Fix versions

Affects versions

2018.08
2018.06.0.1

Priority

Medium