No it's not. You're not stopping any bad behavior with this law, but you're imperiling a vast amount of cooperative and good behavior, or like I said - it's a 'I'm going to punch myself in the face because I don't like you' law. In your scenario, the person in question was a US citizen so this sort of law would not apply.
And that generalizes broadly. Obviously China is engaging in espionage and related activities in the US and, equally obviously, the US is doing so within China. This law does absolutely nothing to shift the ball there whatsoever, but it imposes major hurdles to collaboration that is not only wholly on the up-and-up but directly in the US' best interests to pursue.
Governments are increasingly often engaging in acts with lofty spoken ambitions behind them, but the acts not only fail to do absolutely anything whatsoever to realistically advance those ambitions, but even directly hurt the governments in question. It's absolutely bizarre and I think can only be explained by governments having leadership that surrounds itself with nothing but yes-men, or idiots. Though I suppose, what's the difference?