Naval officer retires after 42 years