static Event parseLegacyEvent()

in invoker/core/src/main/java/com/google/cloud/functions/invoker/BackgroundFunctionExecutor.java [186:196]


  static Event parseLegacyEvent(Reader reader) throws IOException {
    // A Type Adapter is required to set the type of the JsonObject because CloudFunctionsContext
    // is abstract and Gson default behavior instantiates the type provided.
    TypeAdapter<CloudFunctionsContext> typeAdapter = CloudFunctionsContext.typeAdapter(new Gson());
    Gson gson =
        new GsonBuilder()
            .registerTypeAdapter(CloudFunctionsContext.class, typeAdapter)
            .registerTypeAdapter(Event.class, new Event.EventDeserializer())
            .create();
    return gson.fromJson(reader, Event.class);
  }