Release resource.

@param resource
Object
@return boolean, true - if resource is released, false - if the resource still in use.
@throws IOException
if unlock error occurs
329195
public boolean release(final Object resource) throws IOException
   {
      final Thread myThread = Thread.currentThread();
      final VDResource res = resources.get(resource);
      if (res != null)
      {
         if (res.removeUserLock(myThread))
         {
            synchronized (res.lock)
            {
               // unlock holder
               res.lockSupport.unlock();

               // locked by this thread (by me)
               // ...Wakes up a single thread that is waiting on this object's monitor
               res.lock.notify();
               // resources will be reputed with new VDResource in aquire() of another Thread
               resources.remove(resource);
            }
            return true;
         }
      }

      return false;
   }
26997
public static File getResourceAsFile(final String resource) {
        final ClassLoader classLoader = FileUtils.class.getClassLoader();
        final String path = classLoader != null
                ? classLoader.getResource(resource).getFile()
                : ClassLoader.getSystemResource(resource).getFile();

        if (path == null) {
            return new File(resource);
        }
        return new File(path);
    }
506238
public void release() throws Exception {
        synchronized (this) {
            if (log.isDebugEnabled()) {
                log.debug("Releasing lock on " + lockFile.getAbsolutePath());
            }
            if (fileLock != null) {
                try {
                    fileLock.release();
                    fileLock = null;
                } catch (Exception e) {
                    throw new Exception("Unable to release locked file: " + lockFile.getAbsolutePath(), e);
                }
                if (fileChannel != null) {
                    try {
                        fileChannel.close();
                    } catch (IOException e) {
                        // ignore
                    }
                    fileChannel = null;
                }
                if (lockFile != null) {
                    if (lockFile.exists()) {
                        lockFile.delete();
                    }
                    lockFile = null;
                }
            }
        }
    }
1336472
def remove(self, resource):
        """"""
        if isinstance(resource, Resource):
            self._resources.remove(resource)
123519
private void tryUnlock(CmsResource resource) {

        try {
            m_cms.unlockResource(resource);
        } catch (CmsException e) {
            // usually not a problem
            LOG.debug("failed to unlock " + resource.getRootPath(), e);
        }

    }
1306578
public void unlock() throws IOException {
    if (fileLock != null) {
      try {
        fileLock.release();
      } catch (ClosedChannelException e) {
      }
      fileLock = null;
    }
  }
426899
protected boolean isInConditionResource(String resource){
		Resource sqlResource = context.getResource(resource);
		InputStream in = null;
		String sql = null;
		try{
			in = sqlResource.getInputStream();
			sql = IOUtils.toString(in);
		} catch(IOException ioe){
			throw new RuntimeException("Failed to get condition SQL (" + ioe.getMessage() + ") from: " + resource, ioe);
		}finally{
			IOUtils.closeQuietly(in);
		}
		if (StringUtils.isNotBlank(sql)){
			return isInCondition(sql);
		}else{
			return true;
		}
	}
84122
public function isLocked($resource = null): bool
    {
        return $this->hasSharedLock($resource) || $this->hasExclusiveLock($resource);
    }
933094
public void release() {
        if (released.compareAndSet(false, true)) {
            synchronized (releasingLock) {
                if (released.get()) {
                    impl.release(Integer.MAX_VALUE);
                }
            }
        }
    }
1328422
void unlockResource() {

        if (!shouldUnlockAutomatically()) {
            return;
        }
        if (m_entityId != null) {
            final CmsUUID structureId = CmsContentDefinition.entityIdToUuid(m_entityId);
            if (m_deleteOnCancel) {
                CmsRpcAction<Void> action = new CmsRpcAction<Void>() {

                    @Override
                    public void execute() {

                        CmsCoreProvider.getVfsService().syncDeleteResource(structureId, this);
                    }

                    @Override
                    protected void onResponse(Void result) {

                        // nothing to do
                    }
                };
                action.executeSync();
            } else {
                CmsCoreProvider.get().unlock(structureId);
            }
        }
    }
505500
protected function applyLock($resource)
    {
        if ($this->shouldLock === false) {
            $this->lockApplied = false;
            return flock($resource, LOCK_UN);
        }

        $lock = $this->shouldLock === true ? $this->getLockMode() : $this->shouldLock;


        if (!flock($resource, $lock)) {
            return false;
        }

        $this->lockApplied = true;

        return true;
    }
624978
private function close($resource)
    {
        if (is_resource($resource)) {
            fclose($resource);
        }

        if (is_resource($this->process)) {
            proc_close($this->process);
            $this->process = null;
        }

        $this->stdin->close();
    }
730177
public static function close_file($resource, $area = null)
	{
		// If locks aren't used, don't unlock
		if ( static::instance($area)->use_locks())
		{
			flock($resource, LOCK_UN);
		}

		fclose($resource);
	}
801579
public final void release()
                    throws java.io.IOException {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "release");

        // Give up the lock.
        if (fileLock != null)
            fileLock.release();
        fileLock = null;

        if (fileChannel != null)
            fileChannel.close();
        fileChannel = null;

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "release");
    }
1009772
public function close()
    {
        if($resource = $this->getResource())
        {
            if(@fclose($resource) === true)
            {
                $this->_resource = null;
                return true;
            }
        }

        return false;
    }
435790
private boolean releaseFileLock() {

        // Note:  Closing the super class RandomAccessFile has the
        //        side-effect of closing the file lock's FileChannel,
        //        so we do not deal with this here.
        boolean success = false;

        if (this.fileLock == null) {
            success = true;
        } else {
            try {
                this.fileLock.release();

                success = true;
            } catch (Exception e) {}
            finally {
                this.fileLock = null;
            }
        }

        return success;
    }
52621
@SuppressWarnings("unchecked")
  synchronized <T> T getInternal(Resource<T> resource) {
    Instance instance = instances.get(resource);
    if (instance == null) {
      instance = new Instance(resource.create());
      instances.put(resource, instance);
    }
    if (instance.destroyTask != null) {
      instance.destroyTask.cancel(false);
      instance.destroyTask = null;
    }
    instance.refcount++;
    return (T) instance.payload;
  }