Maybe not an attack, but perhaps China or Russia decided one day that it was in their national interest to impose a tax all the output coming out of your country. Say that what were previously international waters and air space became the domain of China after a massive naval build up and required paying money to transit. Say all fishing rights around NZ were annexed by China, etc. etc. It may be the very reason you are on respectful terms with the other superpowers, is that there is another countervailing superpower willing and able to step in if needed.
Okay, let's say that happens in 2050. Unlikely, but assume that. In 30 years.
First of all, of course, they would still do it in case of NZ because China could steamroll all defence. But let's also assume they can't and compare the costs.
Let's further assume the difference is 3% of GDP to today. (Israel level, a small country with high military spending)
3% x30 years is 90%, and that is not even accounting for compound interest. So for easiness sake assume 100%, because then we can go for the 4% rule.
If 2050 China takes a toll of more than 4% (interest on the 3% 30 years) + 3% (GDP for additional military) = 7%, then it is more expensive. (That means China would need to take out (if we take todays level) $14 billion yearly before having military gets cheaper.)
Not impossible, but I don't think that is sustainable in the long run, and Chinese like the long run (which is one of the main reasons why they will take over number one from short sighted USA).
And again, not realistic, since even with 10% of GDP into military it would mean nothing against China, who has 26 times the expenses now.
---
(btw. I was slightly wrong in a former post. If the USA would halve their military expenses, they would not be slightly behind China, they would be slightly behind China and Russia and India
together. It was the next three not only one.)