Source:
<code>SubIndex(Directory dir, final String dirName, GerritIndexWriterConfig writerConfig) throws IOException { this.dir = dir; long commitPeriod = writerConfig.getCommitWithinMs(); if <START> (commitPeriod == -1L) { <END> writer = new TrackingIndexWriter(new IndexWriter(dir, writerConfig.getLuceneConfig())); } else if (commitPeriod == 0) { writer = new TrackingIndexWriter(new AutoCommitWriter(dir, writerConfig.getLuceneConfig(), true)); } else { final AutoCommitWriter delegateWriter = new AutoCommitWriter(dir, writerConfig.getLuceneConfig(), false); writer = new TrackingIndexWriter(delegateWriter); new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder() .setNameFormat("Commit-%d " + dirName) .setDaemon(true) .build()) .scheduleAtFixedRate(new Runnable() { @Override public void run() { try { if (delegateWriter.hasUncommittedChanges()) { delegateWriter.manualFlush(); delegateWriter.commit(); } } catch (IOException e) { log.error("Error committing Lucene index " + dirName, e); } catch (OutOfMemoryError e) { log.error("Error committing Lucene index " + dirName, e); try { delegateWriter.close(); } catch (IOException e2) { log.error("SEVERE: Error closing Lucene index " + dirName + " after OOM; index may be corrupted.", e); } } } }, commitPeriod, commitPeriod, MILLISECONDS); } searcherManager = new SearcherManager( writer.getIndexWriter(), true, new SearcherFactory()); refreshListeners = Maps.newConcurrentMap(); searcherManager.addListener(new RefreshListener() { @Override public void beforeRefresh() throws IOException { } @Override public void afterRefresh(boolean didRefresh) throws IOException { for (RefreshListener l : refreshListeners.keySet()) { l.afterRefresh(didRefresh); } } }); reopenThread = new ControlledRealTimeReopenThread<IndexSearcher>( writer, searcherManager, 0.500 , 0.010 ); reopenThread.setName("NRT " + dirName); reopenThread.setPriority(Math.min( Thread.currentThread().getPriority() + 2, Thread.MAX_PRIORITY)); reopenThread.setDaemon(true); reopenThread.start(); }</code><technical_language>commitPeriod < 0</technical_language>

Target:
SubIndex(Directory dir, final String dirName, GerritIndexWriterConfig writerConfig) throws IOException { this.dir = dir; long commitPeriod = writerConfig.getCommitWithinMs(); if (commitPeriod < 0) { writer = new TrackingIndexWriter(new IndexWriter(dir, writerConfig.getLuceneConfig())); } else if (commitPeriod == 0) { writer = new TrackingIndexWriter(new AutoCommitWriter(dir, writerConfig.getLuceneConfig(), true)); } else { final AutoCommitWriter delegateWriter = new AutoCommitWriter(dir, writerConfig.getLuceneConfig(), false); writer = new TrackingIndexWriter(delegateWriter); new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder() .setNameFormat("Commit-%d " + dirName) .setDaemon(true) .build()) .scheduleAtFixedRate(new Runnable() { @Override public void run() { try { if (delegateWriter.hasUncommittedChanges()) { delegateWriter.manualFlush(); delegateWriter.commit(); } } catch (IOException e) { log.error("Error committing Lucene index " + dirName, e); } catch (OutOfMemoryError e) { log.error("Error committing Lucene index " + dirName, e); try { delegateWriter.close(); } catch (IOException e2) { log.error("SEVERE: Error closing Lucene index " + dirName + " after OOM; index may be corrupted.", e); } } } }, commitPeriod, commitPeriod, MILLISECONDS); } searcherManager = new SearcherManager( writer.getIndexWriter(), true, new SearcherFactory()); refreshListeners = Maps.newConcurrentMap(); searcherManager.addListener(new RefreshListener() { @Override public void beforeRefresh() throws IOException { } @Override public void afterRefresh(boolean didRefresh) throws IOException { for (RefreshListener l : refreshListeners.keySet()) { l.afterRefresh(didRefresh); } } }); reopenThread = new ControlledRealTimeReopenThread<IndexSearcher>( writer, searcherManager, 0.500 , 0.010 ); reopenThread.setName("NRT " + dirName); reopenThread.setPriority(Math.min( Thread.currentThread().getPriority() + 2, Thread.MAX_PRIORITY)); reopenThread.setDaemon(true); reopenThread.start(); }