I was generally aware that the two had been captured when their plane went down over mainland China during the Korean War and that they were not released until the Nixon administration's rapprochement with China, but the entire story is much more complicated and interesting. You can read it here, in a CIA in-house journal article:
Beijing’s capture, imprisonment, and eventual release of CIA officers John T. Downey and Richard G. Fecteau is an amazing story that too few know about today. Shot down over Communist China on their first operational mission in 1952, these young men spent the next two decades imprisoned, often in solitary confinement, while their government officially denied they were CIA officers. Fecteau was released in 1971, Downey in 1973. They came home to an America vastly different from the place they had left, but both adjusted surprisingly well and continue to live full lives.
Even though Downey and Fecteau were welcomed back as heroes by the CIA family more than 30 years ago and their story has been covered in open literature — albeit in short and generally flawed accounts — institutional memory regarding these brave officers has dimmed. Their ordeal is not well known among today’s officers, judging by the surprise and wonder CIA historians encounter when relating it in internal lectures and training courses.
Downey and Fecteau were not joyriding on a CIA support flight over China, as the "generally flawed" accounts had it, but were assigned to that flight in order to operate a winch and recover an agent who was to be picked up from the ground using the All-American System, a modified version of a military mail retrieval technique. [See more on that system here. My thanks to commenter Charles Lathrop for correcting my error in first describing that as the Skyhook system, which was a later development.] However, the agents on the ground had been captured and were fully cooperating with the Chinese, and the support flight was shot down. The doubled agents even sent a signal reporting that the agent extraction had been successful, with the result that the CIA assumed its aircraft must have crashed on its return flight, and all aboard were initially reported dead.
The documentary is titled "Extraordinary Fidelity." You can watch it on YouTube, or - but only if you have an hour to spare - click on the embedded video below.