package retrofit2.converter.gson; import com.google.gson.Gson; import com.google.gson.JsonIOException; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import java.io.IOException; import okhttp3.ResponseBody; import retrofit2.Converter; /* loaded from: classes.dex */ final class GsonResponseBodyConverter implements Converter { private final TypeAdapter adapter; private final Gson gson; /* JADX INFO: Access modifiers changed from: package-private */ public GsonResponseBodyConverter(Gson gson, TypeAdapter typeAdapter) { this.gson = gson; this.adapter = typeAdapter; } @Override // retrofit2.Converter public final T convert(ResponseBody responseBody) throws IOException { JsonReader newJsonReader = this.gson.newJsonReader(responseBody.charStream()); try { T read2 = this.adapter.read2(newJsonReader); if (newJsonReader.peek() == JsonToken.END_DOCUMENT) { return read2; } throw new JsonIOException("JSON document was not fully consumed."); } finally { responseBody.close(); } } }