Closer rethrow - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Closer rethrow method.

This code example shows how to use the following methods:register
      super(content);
   } 
 
   @Override 
   public InputStream openStream() throws IOException {
      return closer.register(content.openStream());
   } 
 
   @Override 
   public boolean isRepeatable() { 
      return true; 
   } 
 
   /** 
    * if we created the stream, then it is already consumed on close. 
    */ 
   @Override 
   public void release() { 
      closeQuietly(closer);
   } 
5
CodeRank
This code example shows how to use the following methods:close
    @Override 
    public final void close() 
    { 
        cancelAllQueries(); 
        try { 
            closer.close();
        } 
        catch (IOException e) {
            throw Throwables.propagate(e);
        } 
    } 
 
    private void cancelAllQueries() 
    { 
        QueryManager queryManager = coordinator.getQueryManager();
        for (QueryInfo queryInfo : queryManager.getAllQueryInfo()) {
            if (!queryInfo.getState().isDone()) {
                queryManager.cancelQuery(queryInfo.getQueryId());
            } 
        } 
4
CodeRank
This code example shows how to use the following methods:register
     * 
     * @return the given {@code closeable} 
     */ 
    protected <C extends Closeable> C autoclose(C closeable)
    { 
        return _closer.register(closeable);
    } 
 
    /** 
     * Registers the given {@code cancellable}. When this tempalte is cancelled so is {@code cancellable}. 
     * 
     * @throws IllegalStateException if called more than once 
     */ 
    protected void setCancellable(Cancellable cancellable)
    { 
        checkState(_cancellable == null);
        _cancellable = checkNotNull(cancellable);
    } 
 
    /** 
4
CodeRank
This code example shows how to use the following methods:close
public class MorphEncodingToolTest extends RandomizedTest { 
    private Closer closer = Closer.create();
 
    @After 
    public void cleanup() throws IOException {
        closer.close();
    } 
     
	@Test
	public void testTool() throws Exception {
		// Create a simple plain text file. 
		File input = super.newTempFile();
		File output = super.newTempFile();
 
		// Populate the file with data. 
		PrintWriter w = 
		    new PrintWriter(
		        new OutputStreamWriter(
		            closer.register(new FileOutputStream(input)), "UTF-8"));
		w.println("passagère\tpassager\ttag");
3
CodeRank
rethrow Method Overview
Stores the given throwable and rethrows it.
See Code Examples for other Guava Closer Methods: