JsonSerialization { @SuppressWarnings("unchecked") public synchronized T load(File jsonFile) throws IOException, JsonParseException, JsonMappingException { if (!jsonFile.isFile()) { throw new FileNotFoundException("Not a file: " + jsonFile); } if (jsonFile.length() == 0) { throw new EOFException("File is empty: " + jsonFile); } try { return mapper.readValue(jsonFile, classType); } catch (IOException e) { LOG.error("Exception while parsing json file {}", jsonFile, e); throw e; } } JsonSerialization(Class<T> classType,
      boolean failOnUnknownProperties, boolean pretty); static ObjectWriter writer(); static ObjectReader mapReader(); String getName(); ObjectMapper getMapper(); @SuppressWarnings("unchecked") synchronized T fromJson(String json); synchronized T fromJsonStream(InputStream stream); @SuppressWarnings("unchecked") synchronized T load(File jsonFile); void save(File file, T instance); @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) synchronized T fromResource(String resource); T fromInstance(T instance); T load(FileSystem fs, Path path); void save(FileSystem fs, Path path, T instance,
      boolean overwrite); byte[] toBytes(T instance); T fromBytes(byte[] bytes); synchronized String toJson(T instance); String toString(T instance);  }
@Test public void testEmptyFile() throws Throwable { File tempFile = File.createTempFile("Keyval", ".json"); try { LambdaTestUtils.intercept(EOFException.class, "empty", () -> serDeser.load(tempFile)); } finally { tempFile.delete(); } }
@Test public void testFileSystemEmptyPath() throws Throwable { File tempFile = File.createTempFile("Keyval", ".json"); Path tempPath = new Path(tempFile.toURI()); LocalFileSystem fs = FileSystem.getLocal(new Configuration()); try { LambdaTestUtils.intercept(EOFException.class, () -> serDeser.load(fs, tempPath)); fs.delete(tempPath, false); LambdaTestUtils.intercept(FileNotFoundException.class, () -> serDeser.load(fs, tempPath)); } finally { fs.delete(tempPath, false); } }