private void receiveFriends(){
  CleartextFriends friendsReceived=CleartextFriends.fromJSON(lengthValueRead(in));
  this.mFriendsReceived=friendsReceived;
  if (mFriendsReceived != null && mFriendsReceived.friends != null) {
    Set<String> myFriends=friendStore.getAllFriends();
    Set<String> theirFriends=new HashSet(mFriendsReceived.friends);
    Set<String> intersection=new HashSet(myFriends);
    intersection.retainAll(theirFriends);
    commonFriends=intersection.size();
    log.info("Received " + theirFriends.size() + " friends. Overlap with my "+ myFriends.size()+ " friends is "+ commonFriends);
  }
 else   if (mFriendsReceived == null) {
    log.info("Friends received is null: " + mFriendsReceived);
    setExchangeStatus(Status.ERROR);
    setErrorMessage("Failed receiving friends.");
  }
 else {
    log.error("Friends received.friends is null");
    setExchangeStatus(Status.ERROR);
    setErrorMessage("Failed receiving friends.");
  }
}

private void receiveFriends ( ) { CleartextFriends friendsReceived = CleartextFriends . fromJSON ( lengthValueRead ( in ) ) ; this . mFriendsReceived = friendsReceived ; if ( mFriendsReceived != null && mFriendsReceived . friends != null ) { Set < String > myFriends = friendStore . getAllFriends ( ) ; Set < String > theirFriends = new HashSet ( mFriendsReceived . friends ) ; Set < String > intersection = new HashSet ( myFriends ) ; intersection . retainAll ( theirFriends ) ; commonFriends = intersection . size ( ) ; log . info ( "Received " + theirFriends . size ( ) + " friends. Overlap with my " + myFriends . size ( ) + " friends is " + commonFriends ) ; } else if ( mFriendsReceived == null ) { log . info ( "Friends received is null: " + mFriendsReceived ) ; setExchangeStatus ( Status . ERROR ) ; setErrorMessage ( "Failed receiving friends." ) ; } else { log . error ( "Friends received.friends is null" ) ; setExchangeStatus ( Status . ERROR ) ; setErrorMessage ( "Failed receiving friends." ) ; } }
receive friends from the remote device .
