U.S. District Judge Roger T. Benitez ruled that the California law violated the Second Amendment rights of gun owners and issued an injunction barring state officials from enforcing it, invoking the nation’s Colonial past as well as recent cases from around the country in which gun owners ran out of bullets while confronting intruders in their homes.