private void closeRestletConnection(ClientResource clientResource) { try { clientResource.getResponseEntity().exhaust(); } catch (IOException e) { logger.warn("Error closing connection: {}", e.getMessage() ); } }
Representation responseRepresentation = response.getEntity(); if (responseRepresentation != null) { try { responseRepresentation.exhaust(); } catch (IOException e) { // handle exception } responseRepresentation.release(); }
@Override public long exhaust() throws IOException { return getWrappedRepresentation().exhaust(); }
public void stop() { this.proxy.stop(); System.out.println("stop\n"); try { if (this.clientResource.getResponseEntity() != null) { this.clientResource.getResponseEntity().exhaust(); } } catch (Exception e) { System.out.println("stop " + e.getMessage()); e.printStackTrace(); } }
public void start() { this.proxy.start(); System.out.println("start\n"); try { if (this.clientResource.getResponseEntity() != null) { this.clientResource.getResponseEntity().exhaust(); } } catch (Exception e) { System.out.println("start " + e.getMessage()); e.printStackTrace(); } }
public void acknowledge() { this.proxy.acknowledge(); System.out.println("acknowledge\n"); try { if (this.clientResource.getResponseEntity() != null) { this.clientResource.getResponseEntity().exhaust(); } } catch (Exception e) { System.out.println("acknowledge " + e.getMessage()); } }
ClientResource cr = new ClientResource(uri); //please substitute the line below with any other kind of request you need to forward Representation response = cr.put(json); if (response != null) { try { <something> }finally { response.exhaust(); response.release(); cr.release(); }
/** * Prints the resource's representation. * * @param clientResource * The Restlet client resource. * @throws IOException * @throws ResourceException */ public static void get(ClientResource clientResource) throws IOException, ResourceException { try { clientResource.get().write(System.out); } catch (ResourceException e) { System.out.println("Error status: " + e.getStatus()); System.out.println("Error message: " + e.getMessage()); // Consume the response's entity which releases the connection clientResource.getResponseEntity().exhaust(); } }
itemsResource.getResponseEntity().exhaust();
response.getEntity().exhaust();
response.getEntity().exhaust();