The rioters were idiots that's for sure.
Side note - semantically speaking - the oath of serving in the Military is to the Constitution - not the currently elected Government. Though lawful obedience to the President and Officers appointed is there as well. So to go against the elected leaders does not "technically" apply to military personnel if actions taken by the elected leaders are in conflict with the Constitution. Just as disobeying an unlawful order from the President or Officers is not considered illegal - though it would be contested in a legal setting.
But again, the rioters were dumb for doing what they did, and should be handled in the legal system.
Edit: Just as the Joint Chiefs statement was correct in preemptive action to avoid any confusion or conflict with regards to any potential illegal orders given by President Trump. They were right in issuing that clear statement to avoid any potential conflict.