public static <T,U extends AutoCloseable>T withAutoCloseable(U self,@ClosureParams(value=FirstParam.class) Closure<T> action) throws Exception {
  try {
    T result=action.call(self);
    AutoCloseable temp=self;
    self=null;
    temp.close();
    return result;
  }
  finally {
    closeWithWarning(self);
  }
}

public static < T , U extends AutoCloseable > T withAutoCloseable ( U self , @ ClosureParams ( value = FirstParam . class ) Closure < T > action ) throws Exception { try { T result = action . call ( self ) ; AutoCloseable temp = self ; self = null ; temp . close ( ) ; return result ; } finally { closeWithWarning ( self ) ; } }
allows this autocloseable to be used within the closure , ensuring that it is closed once the closure has been executed and before this method returns .
