Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexDatabase.getFiles() functionality needs to be investigated #1676

Open
vladak opened this issue Jul 21, 2017 · 1 comment
Open

IndexDatabase.getFiles() functionality needs to be investigated #1676

vladak opened this issue Jul 21, 2017 · 1 comment
Labels

Comments

@vladak
Copy link
Member

vladak commented Jul 21, 2017

When working on test case for #767 I wanted to peruse modified version (so that it returns set of strings instead of writing them to the log) of IndexDatabase#listFiles() and call it like this:

Assert.assertEquals(6, idb.getFiles().size());

however got exception instead:

Testcase: testCleanupAfterIndexRemoval(org.opensolaris.opengrok.index.IndexDatabaseTest):	Caused an ERROR
String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1967)
	at org.opensolaris.opengrok.web.Util.uid2url(Util.java:647)
	at org.opensolaris.opengrok.index.IndexDatabase.getFiles(IndexDatabase.java:1028)
	at org.opensolaris.opengrok.index.IndexDatabaseTest.testCleanupAfterIndexRemoval(IndexDatabaseTest.java:164)

This is curious feature anyway that is being called from Indexer#prepareIndexer:

789          if (listFiles) {
790              IndexDatabase.listAllFiles(subFiles);
791          }

however the listFiles boolean does not have a matching command line option and is set to false by default so likely this code path has not been called for a long time. Hence filing this issue so that it is not forgotten. Either it should be fixed or ripped out.

@vladak vladak added the bug label Jul 21, 2017
@vladak vladak changed the title IndexDatabase.getFiles functionality needs to be investigated IndexDatabase.getFiles() functionality needs to be investigated Jul 21, 2017
@vladak
Copy link
Member Author

vladak commented Jul 28, 2017

Same code for terms traversal is used in IndexDatabase#update() and looks correct according to https://stackoverflow.com/questions/15290980/how-to-get-all-terms-for-a-lucene-field-in-lucene-4 so maybe this was something special about the test testCleanupAfterIndexRemoval() in cset d3dbeac - try to replace the call to idb.getNumFiles() with getFiles().size().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants