protected void closeQuietly( Resource resource ) { try { if (resource != null) { resource.close(); } } catch( Exception ex ) { log( "Exception during Resource.close()", ex ); } }
@Override public void close() { this.delegate.close(); }
public void parse () throws Exception { if (_root == null) { try { XmlParser parser = ensureParser(); _root = parser.parse(_xml.getInputStream()); _dtd = parser.getDTD(); } finally { _xml.close(); } } }
@Override protected void finalize() { close(); }
/** Release any temporary resources held by the resource. * @deprecated use {@link #close()} */ public final void release() { close(); }
@Override public void deconfigure(WebAppContext context) throws Exception { //if we're not persisting the temp dir contents delete it if (!context.isPersistTempDirectory()) { IO.delete(context.getTempDirectory()); } //if it wasn't explicitly configured by the user, then unset it Boolean tmpdirConfigured = (Boolean)context.getAttribute(TEMPDIR_CONFIGURED); if (tmpdirConfigured != null && !tmpdirConfigured) context.setTempDirectory(null); //reset the base resource back to what it was before we did any unpacking of resources if (context.getBaseResource() != null) context.getBaseResource().close(); context.setBaseResource(_preUnpackBaseResource); }
webFrag.close(); webFrag = EmptyResource.INSTANCE;
resourcesDir.close(); resourcesDir = EmptyResource.INSTANCE;
@Override public void close() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) r.close(); }
@Override public void release() { _resource.close(); }
@Override public void closeTemplateSource(Object templateSource) throws IOException { ((Resource) templateSource).close(); } }
protected void closeQuietly( Resource resource ) { try { if (resource != null) { resource.close(); } } catch( Exception ex ) { log( "Exception during Resource.close()", ex ); } }
Resource res = null; try{ res = //aquire resource //do stuff }catch(Exception e /*or whatever*/){ //handle exceptions }finally{ if(null != res){ res.close(); } }
final Resource resource = acquire(); try { use(resource); } finally { resource.close(); }
@Override public void release() { _resource.close(); }
@Override public void close() { if(_resources==null) throw new IllegalStateException("*resources* not set."); for(Resource r : _resources) r.close(); }
protected void invalidate() { // Invalidate it _cachedSize.addAndGet(-_length); _cachedFiles.decrementAndGet(); _resource.close(); }
Resource resource = null; try { resource = new Resource(); // ... } finally { if (resource != null) try { resource.close(); } catch (ResourceException logOrIgnore) {} }
Resource r = new Resource(); try { // do stuff } finally { r.close(); }
protected void invalidate() { ByteBuffer indirect=_indirectBuffer.get(); if (indirect!=null && _indirectBuffer.compareAndSet(indirect,null)) _cachedSize.addAndGet(-BufferUtil.length(indirect)); ByteBuffer direct=_directBuffer.get(); if (direct!=null && !BufferUtil.isMappedBuffer(direct) && _directBuffer.compareAndSet(direct,null)) _cachedSize.addAndGet(-BufferUtil.length(direct)); _cachedFiles.decrementAndGet(); _resource.close(); }