perforceopengrok

OpenGrok History Cache Null Ptr Exception


When indexing it tries to create the history cache for the perforce repo and fails with the following NULL ptr exception:

2015-01-16 10:30:32.178-0800 INFO t1 HistoryGuru.createCacheReal: Creating historycache for 1 repositories
2015-01-16 10:30:32.179-0800 INFO t22 HistoryGuru.createCache: Creating historycache for /local2/mnt/workspace/opengrok/src (PerforceRepository)
2015-01-16 10:30:32.181-0800 FINE t22 Executor.exec: Executing command [/pkg/qct/software/p4/p4, dirs, *] in directory /local2/mnt/workspace/opengrok/src
2015-01-16 10:30:32.458-0800 FINE t22 Executor.exec: Finished command [/pkg/qct/software/p4/p4, dirs, *] in directory /local2/mnt/workspace/opengrok/src
2015-01-16 10:30:32.459-0800 FINE t22 Executor.exec: Executing command [p4, changes, -t, ...] in directory /local2/mnt/workspace/opengrok/src
2015-01-16 10:30:39.230-0800 FINE t22 Executor.exec: Finished command [p4, changes, -t, ...] in directory /local2/mnt/workspace/opengrok/src
2015-01-16 10:30:39.366-0800 FINE t22 FileHistoryCache.store: Storing history for repo /local2/mnt/workspace/opengrok/src
2015-01-16 10:30:39.369-0800 WARNING t22 FileHistoryCache.storeLatestCachedRevision: cannot write latest cached revision to file: null
2015-01-16 10:30:39.369-0800 WARNING t22 HistoryGuru.createCache: An error occured while creating cache for /local2/mnt/workspace/opengrok/src (PerforceRepository)
java.lang.NullPointerException
    at org.opensolaris.opengrok.history.FileHistoryCache.storeLatestCachedRevision(FileHistoryCache.java:595

I've checked the user has write permissions to $OPENGROK_INSTANCE_BASE/data. Any ideas to what else to check or what may be going on?

OpenGrok Version: 0.12.1.1 Indexing cmd:

OPENGROK_TAG=1 OPENGROK_VERBOSE=1 OPENGROK_REMOTE_REPOS_OFF=0 OPENGROK_TOMCAT_CASE=/usr/share/tomcat7 OPENGROK_INSTANCE_BASE=/local2/mnt/workspace/opengrok ./OpenGrok index /local2/mnt/workspace/opengrok/src/

Solution

  • Turns out this is a bug in OpenGrok. See thread: https://github.com/OpenGrok/OpenGrok/issues/878

    In short, src/org/opensolaris/opengrok/history/FileHistoryCache.java needs a NULL ptr check.

     @@ -592,7 +592,9 @@ private void storeLatestCachedRevision(Repository repository, String rev) {
                     ex.getCause());
             } finally {
                try {
    -               writer.close();
    +               if (writer != null) {
    +                   writer.close();
    +               }
                } catch (IOException ex) {
                    logger.log(Level.INFO, "cannot close file: " + ex);
                }
    

    https://github.com/OpenGrok/OpenGrok/commit/0dbb0e366b3798ac18d1bfc010a1985bce75f071

    Why the file writer is NULL in the first place is another question...