code: public static <O> O deserialise(Path input, Class<O> jsonType, int attempt) throws IOException {
          O result = null;
          //if (attempt > 0)
          //    System.out.println("Retrying deserialisation.. (" + attempt + ")");
  
          Gson gson = getBuilder().create();
          try (FileChannel inputChannel = FileChannel.open(input, StandardOpenOption.READ)) {
              // NB the lock will be released when the channel is closed:
              readLock(inputChannel);
              try (Reader reader = new BufferedReader(Channels.newReader(inputChannel, StandardCharsets.UTF_8.name()))) {
                  result = gson.fromJson(reader, jsonType);
              } catch (JsonSyntaxException | JsonIOException | NumberFormatException e) {
                  // Very occasionally, with 1000 threads, the content comes back invalid, so we'll retry.
                  if (attempt >= 5) {
                      throw e;
                  }
              }
          }
  
          // Very occasionally, with 1000 threads, no content is read so we'll retry if the result is null.
          if (result == null && attempt < 5) {
              result = deserialise(input, jsonType, ++attempt);
          }
  
          return result;
      }
docs: Deserialises the given {@link InputStream} to a JSON String.
  
  @param input    The stream to deserialise.
  @param jsonType The object type to deserialise into.
  @param attempt  The retry attempt. This has an arbitrary maximum of 5.
  @param <O>      The type to deserialise to.
  @return A new instance of the given type.
  @throws IOException If an error occurs in reading from the input stream.