I can understand wanting to avoid torture, like if the enemy rounded up villagers and gave them statements to make under threat of torture or death--I don't think that would be treasonous on the part of the villagers. But, when it comes to the military, it's expected that they understand the dangers they will run into, and that their first duty is to their country. They are expected to stand up to torture in order to keep the country and their fellow soldiers safe. McCain got the nickname Songbird because he was eager to give out the information. If he gained weight while in captivity, he must've gotten special treatment for his willingness to talk. That probably means that he never actually underwent any torture, simply because they didn't need to torture him to get the info.
I could even understand avoiding torture if he had been drafted, but he volunteered to join the Navy, and he came from a military family (father and grandfather were Navy admirals).