<commit_before>package net.tomp2p.relay;

import net.tomp2p.connection.PeerConnection;
import net.tomp2p.connection.Responder;
import net.tomp2p.futures.FuturePeerConnection;
import net.tomp2p.message.Message;
import net.tomp2p.p2p.Peer;
import net.tomp2p.peers.PeerAddress;
import net.tomp2p.rpc.DirectDataRPC;

public class PermanentConnectionRPC extends DirectDataRPC {
	
	private FuturePeerConnection futurePeerConnection = null;
	private final Peer peer;
	private final PeerAddress unreachablePeer;
	

	public PermanentConnectionRPC(Peer peer, PeerAddress unreachablePeer) {
		super(peer.getPeerBean(), peer.getConnectionBean());
		this.peer = peer;
		this.unreachablePeer = unreachablePeer;
	}
	
    @Override
    public void handleResponse(final Message message, PeerConnection peerConnection, final boolean sign, Responder responder) throws Exception {

    	if(message.getSender().equals(unreachablePeer) && futurePeerConnection == null) {
    		futurePeerConnection = new FuturePeerConnection(message.getSender());
            futurePeerConnection.setDone(peerConnection);
            new RelayForwarder(futurePeerConnection, peer);
    	}
        super.handleResponse(message, peerConnection, sign, responder);
    }

}
<commit_msg>Restore direct data rpc after permanent connection to relay peer has been established<commit_after>package net.tomp2p.relay;

import net.tomp2p.connection.PeerConnection;
import net.tomp2p.connection.Responder;
import net.tomp2p.futures.FuturePeerConnection;
import net.tomp2p.message.Message;
import net.tomp2p.p2p.Peer;
import net.tomp2p.peers.PeerAddress;
import net.tomp2p.rpc.DirectDataRPC;

public class PermanentConnectionRPC extends DirectDataRPC {
	
	private FuturePeerConnection futurePeerConnection = null;
	private final Peer peer;
	private final PeerAddress unreachablePeer;
	private final DirectDataRPC originalDirectDataRPC;
	

	public PermanentConnectionRPC(Peer peer, PeerAddress unreachablePeer) {
		super(peer.getPeerBean(), peer.getConnectionBean());
		this.peer = peer;
		this.unreachablePeer = unreachablePeer;
		this.originalDirectDataRPC = peer.getDirectDataRPC();
	}
	
    @Override
    public void handleResponse(final Message message, PeerConnection peerConnection, final boolean sign, Responder responder) throws Exception {

    	if(message.getSender().equals(unreachablePeer) && futurePeerConnection == null) {
    		futurePeerConnection = new FuturePeerConnection(message.getSender());
            futurePeerConnection.setDone(peerConnection);
            new RelayForwarder(futurePeerConnection, peer);
            
            // "restore" original direct data RPC
            peer.setDirectDataRPC(originalDirectDataRPC);
    	}
        super.handleResponse(message, peerConnection, sign, responder);
    }

}

{'fraction_non_alphanumeric': 0.08073196986006459, 'fraction_numerical': 0.006458557588805167, 'mean_word_length': 4.881856540084388, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3632069', 'n_tokens_mistral': 819, 'n_tokens_neox': 781, 'n_words': 170}