code: private void ensureLengthForWrite(int ilength) {
          if (ilength > mLength) {
              if (ilength <= mData.length) {
                  mLength = ilength;
              } else {
                  int newLength = mData.length * 2;
                  if (newLength < ilength) {
                      newLength = ilength;
                  }
                  byte[] newData = new byte[newLength];
                  System.arraycopy(mData, 0, newData, 0, mLength);
                  mData = newData;
              }
              mLength = ilength;
          }
      }
docs: Caller must be synchronized