LocalTextModificationAccessor implements ModificationReader, ModificationWriter, AutoCloseable { @Override public Collection<Modification> read() { if (!FSFactoryProducer.getFSFactory().getFile(filePath).exists()) { logger.debug("No modification has been written to this file"); return new ArrayList<>(); } String line; List<Modification> modificationList = new ArrayList<>(); try(BufferedReader reader = FSFactoryProducer.getFSFactory().getBufferedReader(filePath)) { while ((line = reader.readLine()) != null) { if (line.equals(ABORT_MARK) && !modificationList.isEmpty()) { modificationList.remove(modificationList.size() - 1); } else { modificationList.add(decodeModification(line)); } } } catch (IOException e) { logger.error("An error occurred when reading modifications, and the remaining modifications " + "were ignored.", e); } return modificationList; } LocalTextModificationAccessor(String filePath); @Override Collection<Modification> read(); @Override void close(); @Override void abort(); @Override void write(Modification mod);  }
@Test public void readNull() throws IOException { String tempFileName = TestConstant.BASE_OUTPUT_PATH.concat("mod.temp"); LocalTextModificationAccessor accessor; accessor = new LocalTextModificationAccessor(tempFileName); new File(tempFileName).delete(); Collection<Modification> modifications = accessor.read(); assertEquals(new ArrayList<>(), modifications); }