apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.45k stars 973 forks source link

Null exception occured when click on Luke desktop browser button #13345

Open wuth opened 1 month ago

wuth commented 1 month ago

Description

When I have set my share folder (luncene data) on window,I found that Luke desktop's path browser button occurd null exception. like path \xxx.xxx.xx.xx\trace . Finally I debug the source code and repair this bug as follow: java file:OpenIndexDialogFactory.java function:getLastOpenedDirectory

error:path.getParent()

repair:

   private File getLastOpenedDirectory() {
      List<String> history = prefs.getHistory();
      if (!history.isEmpty()) {
        Path path = Paths.get(history.get(0));
        if (Files.exists(path)) {
          if(path.getParent() != null) {
            return path.getParent().toAbsolutePath().toFile();
          }else {
            return path.toAbsolutePath().toFile();
          }
        }
      }
      return null;
    }

Version and environment details

Luncene 8.11.2 and I have check the newest version code has the same problem.

slow-J commented 2 weeks ago

Hi @wuth, please raise a pull request with your fix and it can get reviewed and released.