If the object has already been written, just write its ref.

@return true if we're writing a ref.
425390
public boolean addRef(Object object)
        throws IOException
    {
        if (_refs == null)
            _refs = new IdentityHashMap();

        Integer ref = (Integer) _refs.get(object);

        if (ref != null) {
            int value = ref.intValue();

            writeRef(value);
            return true;
        }
        else {
            _refs.put(object, new Integer(_refs.size()));

            return false;
        }
    }
700928
@Override
    public boolean replaceRef(Object oldRef, Object newRef)
        throws IOException
    {
        if (_isUnshared) {
            return false;
        }

        int value = _refs.get(oldRef);

        if (value >= 0) {
            addRef(newRef, value, true);

            _refs.remove(oldRef);

            return true;
        }
        else
            return false;
    }
1263923
public boolean save() 
    {
        boolean    blnRet    = false;
        File       objFile   = null;
        String     strName   = null;
        String     strTemp   = null;
        Iterator<String>   itrSec    = null;
        INISection objSec    = null;
        FileWriter objWriter = null;

        try
        {
            if (this.mhmapSections.size() == 0) return false;
            objFile = new CSFile(this.mstrFile);
            if (objFile.exists()) objFile.delete();
            objWriter = new FileWriter(objFile);
            itrSec = this.mhmapSections.keySet().iterator();
            while (itrSec.hasNext())
            {
                strName = (String) itrSec.next();
                objSec = (INISection) this.mhmapSections.get(strName);
                strTemp = objSec.toString();
                objWriter.write(strTemp);
                objWriter.write("\r\n");
                objSec = null;
            }
            blnRet = true;
        }
        catch (IOException IOExIgnore)
        {
        }
        finally
        {
            if (objWriter != null)
            {
                closeWriter(objWriter);
                objWriter = null;
            }
            if (objFile != null) objFile = null;
            if (itrSec != null) itrSec = null;
        }
        return blnRet;
    }
448863
private boolean processPendingWrites() {
        long traceId = LoggerHelpers.traceEnterWithContext(log, this.traceObjectId, "processPendingWrites");

        // Clean up the write queue of all finished writes that are complete (successfully or failed for good)
        val cs = this.writes.removeFinishedWrites();
        if (cs == WriteQueue.CleanupStatus.WriteFailed) {
            // We encountered a failed write. As such, we must close immediately and not process anything else.
            // Closing will automatically cancel all pending writes.
            close();
            LoggerHelpers.traceLeave(log, this.traceObjectId, "processPendingWrites", traceId, cs);
            return false;
        } else if (cs == WriteQueue.CleanupStatus.QueueEmpty) {
            // Queue is empty - nothing else to do.
            LoggerHelpers.traceLeave(log, this.traceObjectId, "processPendingWrites", traceId, cs);
            return true;
        }

        // Get the writes to execute from the queue.
        List<Write> toExecute = getWritesToExecute();

        // Execute the writes, if any.
        boolean success = true;
        if (!toExecute.isEmpty()) {
            success = executeWrites(toExecute);

            if (success) {
                // After every run where we did write, check if need to trigger a rollover.
                this.rolloverProcessor.runAsync();
            }
        }

        LoggerHelpers.traceLeave(log, this.traceObjectId, "processPendingWrites", traceId, toExecute.size(), success);
        return success;
    }
852851
public function writesDone()
    {
        if (!$this->has_real_call) {
            $this->createRealCall();
            $this->has_real_call = true;
        }
        $this->real_call->writesDone();
    }
1173789
public final boolean tryLockForWrite(L locker) {
        int state = mState;
        if (state == 0) {
            // no locks are held
            if (isUpgradeOrReadWriteFirst() && setWriteLock(state)) {
                // keep upgrade state bit clear to indicate automatic upgrade
                mOwner = locker;
                incrementUpgradeCount();
                incrementWriteCount();
                return true;
            }
        } else if (state == LOCK_STATE_UPGRADE) {
            // only upgrade lock is held; upgrade to full write lock
            if (mOwner == locker && setWriteLock(state)) {
                incrementWriteCount();
                return true;
            }
        } else if (state < 0) {
            // write lock is held, and upgrade lock might be held too
            if (mOwner == locker) {
                incrementWriteCount();
                return true;
            }
        }
        return false;
    }
1143369
@Override
   void writeEquals(Definition def, Writer out, int indent) throws IOException
   {
      writeIndent(out, indent);
      out.write("/** \n");
      writeIndent(out, indent);
      out.write(" * Indicates whether some other object is equal to this one.\n");
      writeIndent(out, indent);
      out.write(" * @param other The reference object with which to compare.\n");
      writeIndent(out, indent);
      out.write(" * @return true if this object is the same as the obj argument, false otherwise.\n");
      writeIndent(out, indent);
      out.write(" */\n");

      writeIndent(out, indent);
      out.write("@Override\n");
      writeIndent(out, indent);
      out.write("public boolean equals(Object other)");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "if (other == null)\n");
      writeWithIndent(out, indent + 2, "return false;\n");
      writeWithIndent(out, indent + 1, "if (other == this)\n");
      writeWithIndent(out, indent + 2, "return true;\n");
      writeWithIndent(out, indent + 1, "if (!(other instanceof " + getClassName(def) + "))\n");
      writeWithIndent(out, indent + 2, "return false;\n");

      writeWithIndent(out, indent + 1, "boolean result = true;\n");

      if (getConfigProps(def).size() > 0)
      {
         writeIndent(out, indent + 1);
         out.write(getClassName(def) + " obj = (" + getClassName(def) + ")other;\n");
      }

      for (int i = 0; i < getConfigProps(def).size(); i++)
      {
         writeWithIndent(out, indent + 1, "if (result)");
         writeLeftCurlyBracket(out, indent + 1);
         writeWithIndent(out, indent + 2, "if (" + getConfigProps(def).get(i).getName() + " == null)\n");
         writeWithIndent(out, indent + 3,
               "result = obj.get" + upcaseFirst(getConfigProps(def).get(i).getName()) + "() == null;\n");

         writeWithIndent(out, indent + 2, "else\n");
         writeWithIndent(out, indent + 3, "result = " + getConfigProps(def).get(i).getName() + ".equals(obj.get" +
               upcaseFirst(getConfigProps(def).get(i).getName()) + "());");
         writeRightCurlyBracket(out, indent + 1);
      }
      writeWithIndent(out, indent + 1, "return result;");
      writeRightCurlyBracket(out, indent);
      //writeEol(out);
   }
181280
public boolean write()
    {
        assert state == State.WRITING;

        boolean writeFailed = false;

        try
        {
            if (response.streamTo(transport) < 0)
            {
                writeFailed = true;
                return false;
            }
            else if (!response.isFullyStreamed())
            {
                // if socket couldn't accommodate whole write buffer,
                // continue writing when we get next write signal.

                switchToWrite();
                return true;
            }
        }
        catch (IOException e)
        {
            logger.error("Got an IOException during write!", e);
            writeFailed = true;
            return false;
        }
        finally
        {
            if (writeFailed || response.isFullyStreamed())
                response.close();
        }



        // we're done writing. Now we need to switch back to reading.
        switchToRead();

        return true;
    }
925053
public int addRef(Object ref)
    {
        if (_refs == null)
            _refs = new ArrayList();

        _refs.add(ref);

        return _refs.size() - 1;
    }
961658
@Override
    public void writeObject(Object obj, AbstractHessianOutput out)
        throws IOException
    {
        if (out.addRef(obj)) {
            return;
        }

        int ref = out.writeObjectBegin(getClassName(obj));

        if (ref < -1) {
            out.writeString("value");

            InputStream is = null;

            try {
                is = getInputStream(obj);
            } catch (Exception e) {
                log.log(Level.WARNING, e.toString(), e);
            }

            if (is != null) {
                try {
                    out.writeByteStream(is);
                } finally {
                    is.close();
                }
            } else {
                out.writeNull();
            }

            out.writeMapEnd();
        }
        else {
            if (ref == -1) {
                out.writeClassFieldLength(1);
                out.writeString("value");

                out.writeObjectBegin(getClassName(obj));
            }

            InputStream is = null;

            try {
                is = getInputStream(obj);
            } catch (Exception e) {
                log.log(Level.WARNING, e.toString(), e);
            }

            try {
                if (is != null)
                    out.writeByteStream(is);
                else
                    out.writeNull();
            } finally {
                if (is != null)
                    is.close();
            }
        }
    }
827554
public String getWriteMethod() {
        return setterName != null ? setterName :
		        "set" + this.name.substring( 0, 1 ).toUpperCase() + this.name.substring( 1 );
    }
827440
private boolean markAsObsolete(ContentReference ref) {
        if (obsoleteContents.containsKey(ref.getHexHash())) { //This content is already marked as obsolete
            if (obsoleteContents.get(ref.getHexHash()) + obsolescenceTimeout < System.currentTimeMillis()) {
                DeploymentRepositoryLogger.ROOT_LOGGER.obsoleteContentCleaned(ref.getContentIdentifier());
                removeContent(ref);
                return true;
            }
        } else {
            obsoleteContents.put(ref.getHexHash(), System.currentTimeMillis()); //Mark content as obsolete
        }
        return false;
    }
102561
def _do_write(self):
        
        with self.lock:
            self._commit_counter += 1
            if self._commit_counter >= self._commit_every:
                self._db.commit()
                self._commit_counter = 0
733521
public boolean redo() {
    LOGGER.trace("redo, before, size: " + changes.size() + " pos: " + position.get()
        + " validPos: " + validPosition.get());
    Change nextChange = next();
    if (nextChange != null) {
      doWithoutListeners(nextChange.getSetting(), nextChange::redo);
      LOGGER.trace("redo, after, size: " + changes.size() + " pos: " + position.get()
          + " validPos: " + validPosition.get());
      return true;
    }
    return false;
  }
621783
private boolean write(Pipe pipe, Msg msg)
    {
        if (!pipe.write(msg)) {
            Collections.swap(pipes, pipes.indexOf(pipe), matching - 1);
            matching--;
            Collections.swap(pipes, pipes.indexOf(pipe), active - 1);
            active--;
            Collections.swap(pipes, active, eligible - 1);
            eligible--;
            return false;
        }
        if (!msg.hasMore()) {
            pipe.flush();
        }
        return true;
    }
816105
private boolean cleanUp(Reference<?> reference) {
    Method finalizeReferentMethod = getFinalizeReferentMethod();
    if (finalizeReferentMethod == null) {
      return false;
    }
    do {
      /*
       * This is for the benefit of phantom references. Weak and soft
       * references will have already been cleared by this point.
       */
      reference.clear();

      if (reference == frqReference) {
        /*
         * The client no longer has a reference to the
         * FinalizableReferenceQueue. We can stop.
         */
        return false;
      }

      try {
        finalizeReferentMethod.invoke(reference);
      } catch (Throwable t) {
        logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
      }

      /*
       * Loop as long as we have references available so as not to waste
       * CPU looking up the Method over and over again.
       */
    } while ((reference = queue.poll()) != null);
    return true;
  }
1250683
def _is_writable(self, obj):
        """"""
        try:
            write = getattr(obj, 'write')
        except AttributeError:
            return False
        else:
            return is_method(write, min_arity=1, max_arity=1)