oracle / opengrok

OpenGrok is a fast and usable source code search and cross reference engine, written in Java
http://oracle.github.io/opengrok/
Other
4.36k stars 748 forks source link

java.lang.NullPointerException in AccuRevRepository.getDepotRelativePath #3052

Open SreyasSultan opened 4 years ago

SreyasSultan commented 4 years ago

Describe the bug

java.lang.NullPointerException happens when I do a code search after my project got indexed. at

org.opensolaris.opengrok.history.AccuRevRepository.getDepotRelativePath(AccuRevRepository.java:461)
    at org.opensolaris.opengrok.history.AccuRevHistoryParser.parse(AccuRevHistoryParser.java:69)
    at org.opensolaris.opengrok.history.AccuRevRepository.getHistory(AccuRevRepository.java:504)
    at org.opensolaris.opengrok.history.FileHistoryCache.get(FileHistoryCache.java:590)
    at org.opensolaris.opengrok.history.HistoryGuru.getHistory(HistoryGuru.java:258)
    at org.opensolaris.opengrok.history.HistoryGuru.getHistory(HistoryGuru.java:214)
    at org.opensolaris.opengrok.web.PageConfig.getLatestRevision(PageConfig.java:1229)
    at org.opensolaris.opengrok.web.PageConfig.getLatestRevisionLocation(PageConfig.java:1273)
    at org.apache.jsp.list_jsp._jspService(list_jsp.java:926)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
    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.opensolaris.opengrok.web.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:41)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.opensolaris.opengrok.web.StatisticsFilter.doFilter(StatisticsFilter.java:55)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.opensolaris.opengrok.web.AuthorizationFilter.doFilter(AuthorizationFilter.java:86)
    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.http11.Http11Processor.service(Http11Processor.java:800)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    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:748)

OS - Fedora 20 Tomcat - Apache Tomcat/8.5.33 JDK - java version "1.8.0_131" OpenGrok - opengrok-1.1-rc21 Source type - GIT source

To Reproduce After indexing my GIT source, if I search a file "CVT.cc". It shows "java.lang.NullPointerException" as above snippets

Expected behavior Should be able to search those source after indexing.

Screenshots Couldn't share the screen shots

Additional context Add any other context about the problem here.

vladak commented 4 years ago

You are saying that Git project is searched however the NPE happens in AccuRev repository. Do you use AccuRev at all ?

Could you post the contents of your configuration.xml file ? Could you try upgrading to the most recent OpenGrok version and see if the problem persists ?

vladak commented 4 years ago

For the record the NPE happens here (using ~1.1-rc21 source code):

453      public String getDepotRelativePath(File file) {
454  
455          String path = depotRoot;
456          try {
457              // This should turn any symbolically linked paths into the real thing...
458              Path realPath = Paths.get(file.toString()).toRealPath();
459              // ... so that removing the workspace root will give the depot relative path
460              //     (Note realPath should always be starting with wsRoot.)
461              String relativePath = realPath.toString().substring(wsRoot.length());
462  
463              if (relativePath.length() > 0) {
464                  path = Paths.get(depotRoot, relativePath).toString();
465              }
466  

I think the NPE is most likely caused by wsRoot to be null as it is its default value. Anyhow, if the repository is not Accurev the code should not have been executed in the first place.

The code has not changed since so likely the issue exists in the current code base.