elvishew/xLog

cleanLogFilesIfNecessary空指针异常

Closed this issue · 1 comments

报错如下:

E/AndroidRuntime: FATAL EXCEPTION: Thread-1804
                  Process: com.reizx.zues.arua, PID: 29446
                  java.lang.NullPointerException: Attempt to get length of null array
                      at com.elvishew.xlog.printer.file.FilePrinter.cleanLogFilesIfNecessary(FilePrinter.java:161)
                      at com.elvishew.xlog.printer.file.FilePrinter.doPrintln(FilePrinter.java:130)
Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang.NullPointerException''. Check device logcat for details
                      at com.elvishew.xlog.printer.file.FilePrinter.access$200(FilePrinter.java:39)
                      at com.elvishew.xlog.printer.file.FilePrinter$Worker.run(FilePrinter.java:358)                      at java.lang.Thread.run(Thread.java:818)
Test running failed: Instrumentation run failed due to 'java.lang.NullPointerException'

代码位置:

 /**
   * Clean log files if should clean follow strategy
   */
  private void cleanLogFilesIfNecessary() {
    File logDir = new File(folderPath);
    File[] files = logDir.listFiles(); // files 获取得到了空指针
    //此处是不是需要加个空指针判断
    for (File file : files) {
      if (cleanStrategy.shouldClean(file)) {
          file.delete();
      }
    }
  }

@kigkrazy It is a bug, already fixed.

Duplicated with #59

Use v1.6.1