Tabnine Logo
ResponseBody.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
okhttp3.ResponseBody

Best Java code snippets using okhttp3.ResponseBody.close (Showing top 20 results out of 1,278)

origin: square/retrofit

 @Override public Void convert(ResponseBody value) {
  value.close();
  return null;
 }
}
origin: square/retrofit

 @Override public Unit convert(ResponseBody value) {
  value.close();
  return Unit.INSTANCE;
 }
}
origin: square/retrofit

@Override public void close() {
 delegate.close();
}
origin: spring-projects/spring-framework

@Override
public void close() {
  ResponseBody body = this.response.body();
  if (body != null) {
    body.close();
  }
}
origin: square/okhttp

/**
 * Closes the response body. Equivalent to {@code body().close()}.
 *
 * <p>It is an error to close a response that is not eligible for a body. This includes the
 * responses returned from {@link #cacheResponse}, {@link #networkResponse}, and {@link
 * #priorResponse()}.
 */
@Override public void close() {
 if (body == null) {
  throw new IllegalStateException("response is not eligible for a body and must not be closed");
 }
 body.close();
}
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  try {
   return parser.parseFrom(value.byteStream(), registry);
  } catch (InvalidProtocolBufferException e) {
   throw new RuntimeException(e); // Despite extending IOException, this is data mismatch.
  } finally {
   value.close();
  }
 }
}
origin: square/okhttp

public void run() throws Exception {
 Request request = new Request.Builder()
   .url("https://publicobject.com/helloworld.txt")
   .build();
 Response response = client.newCall(request).execute();
 response.body().close();
}
origin: bumptech/glide

@Override
public void cleanup() {
 try {
  if (stream != null) {
   stream.close();
  }
 } catch (IOException e) {
  // Ignored
 }
 if (responseBody != null) {
  responseBody.close();
 }
 callback = null;
}
origin: square/retrofit

 @Override public ResponseBody convert(ResponseBody value) throws IOException {
  try {
   // Buffer the entire body to avoid future I/O.
   return Utils.buffer(value);
  } finally {
   value.close();
  }
 }
}
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  try {
   return adapter.decode(value.source());
  } finally {
   value.close();
  }
 }
}
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  try {
   return adapter.readValue(value.charStream());
  } finally {
   value.close();
  }
 }
}
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  try {
   Unmarshaller unmarshaller = context.createUnmarshaller();
   XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(value.charStream());
   return unmarshaller.unmarshal(streamReader, type).getValue();
  } catch (JAXBException | XMLStreamException e) {
   throw new RuntimeException(e);
  } finally {
   value.close();
  }
 }
}
origin: org.springframework/spring-web

@Override
public void close() {
  ResponseBody body = this.response.body();
  if (body != null) {
    body.close();
  }
}
origin: google/ExoPlayer

/**
 * Closes the current connection quietly, if there is one.
 */
private void closeConnectionQuietly() {
 if (response != null) {
  Assertions.checkNotNull(response.body()).close();
  response = null;
 }
 responseByteStream = null;
}
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  try {
   T read = serializer.read(cls, value.charStream(), strict);
   if (read == null) {
    throw new IllegalStateException("Could not deserialize body as " + cls);
   }
   return read;
  } catch (RuntimeException | IOException e) {
   throw e;
  } catch (Exception e) {
   throw new RuntimeException(e);
  } finally {
   value.close();
  }
 }
}
origin: square/picasso

 @Override public void close() {
  closed.set(true);
  super.close();
 }
};
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  JsonReader jsonReader = gson.newJsonReader(value.charStream());
  try {
   T result = adapter.read(jsonReader);
   if (jsonReader.peek() != JsonToken.END_DOCUMENT) {
    throw new JsonIOException("JSON document was not fully consumed.");
   }
   return result;
  } finally {
   value.close();
  }
 }
}
origin: alibaba/fastjson

  public T convert(ResponseBody value) throws IOException {
    try {
      return JSON.parseObject(value.bytes()
          , fastJsonConfig.getCharset()
          , type
          , fastJsonConfig.getParserConfig()
          , fastJsonConfig.getParseProcess()
          , JSON.DEFAULT_PARSER_FEATURE
          , fastJsonConfig.getFeatures()
      );
    } catch (Exception e) {
      throw new IOException("JSON parse error: " + e.getMessage(), e);
    } finally {
      value.close();
    }
  }
}
origin: square/retrofit

 return Response.error(bufferedBody, rawResponse);
} finally {
 rawBody.close();
rawBody.close();
return Response.success(null, rawResponse);
origin: square/retrofit

 @Override public T convert(ResponseBody value) throws IOException {
  BufferedSource source = value.source();
  try {
   // Moshi has no document-level API so the responsibility of BOM skipping falls to whatever
   // is delegating to it. Since it's a UTF-8-only library as well we only honor the UTF-8 BOM.
   if (source.rangeEquals(0, UTF8_BOM)) {
    source.skip(UTF8_BOM.size());
   }
   JsonReader reader = JsonReader.of(source);
   T result = adapter.fromJson(reader);
   if (reader.peek() != JsonReader.Token.END_DOCUMENT) {
    throw new JsonDataException("JSON document was not fully consumed.");
   }
   return result;
  } finally {
   value.close();
  }
 }
}
okhttp3ResponseBodyclose

Popular methods of ResponseBody

  • string
    Returns the response as a string decoded with the charset of the Content-Type header. If that header
  • byteStream
  • source
  • contentType
  • contentLength
    Returns the number of bytes in that will returned by #bytes, or #byteStream, or -1 if unknown.
  • bytes
    Returns the response as a byte array.This method loads entire response body into memory. If the resp
  • create
    Returns a new response body that transmits content.
  • charStream
    Returns the response as a character stream decoded with the charset of the Content-Type header. If t
  • charset
  • getClass

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Permission (java.security)
    Legacy security code; do not use.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now