Notwithstanding the provisions of clause (A), any officer who would otherwise be discharged under such clause and is within two years of qualifying for retirement under section
3911,
6323, or
8911 of this title, shall unless he is sooner retired or discharged under some other provision of law, be retained on active duty until he is qualified for retirement under that section and then be retired.