Municipal bonds have long been among the safest investments, but a coming wave of municipal bankruptcies in California—and the disturbing way one of those cities is stiffing its bondholders—could change perceptions about such bonds’ safety.

The struggling port city of Stockton has declared bankruptcy after a spending spree where officials granted workers an absurdly generous lifetime medical care benefit, dramatically increased pensions, and floated debt to finance dubious downtown redevelopment projects.

When the city couldn’t make its pension payments in 2007, it borrowed $125 million in bonds to cover the mess it created by its pension increases. Now the city government is as upside-down as many of its homeowners and officials are blaming the foreclosure crisis, conveniently neglecting that the current reduction in property tax revenue has come after years of dramatic increases in such revenue.

Now Stockton officials want to stiff Assured Guaranty, the Bermuda-based bond insurance company, for about $103 million. The company—noting that Stockton is going under in part because it can’t make its pension payments to the California Public Employee’s Retirement System—argued in a statement, “If Stockton is disappointed with CalPERS’ investment performance, it should be taking that up with CalPERS rather than reneging on the city's obligation to holders of the pension bonds.”

Stockton’s city manager Bob Deis accused the company of “bad faith” and “whining” even as he whined that Assured Guaranty doesn’t care about anarchy in Stockton’s streets, as the city’s crime rate soars after police cutbacks.

But it’s not the fault of lenders that city officials are so unconcerned about the safety of their residents that they continually put the demands of wealthy pensioners above the needs of local residents. Like many cities in this state, Stockton’s infrastructure is crumbling as officials serve mainly as benefit providers to those who work for the city or who are retired from city government.

Deis’s statement is the equivalent of a wastrel who spent 10 years running up debt on luxurious living, then got mad at his bank for wanting to get paid back: “Hey, you don’t care that I can’t feed my kids!”

Of course, it’s hard to top the arrogance of the scandal-plagued CalPERS, which has responded to Assured Guaranty’s complaints by insisting that “obligations owed to the public workers of the city have priority” over creditors such as Assured Guaranty. CalPERS also insists the media is “hyping” the idea that pension promises have anything to do with cities going belly up. CalPERS, which in 1999 advocated retroactive pension increases based on assumed rates of returns that essentially required the Dow Jones to reach 25,000 by 2009, is backed by taxpayers whether its projections are right or wrong.

As cities run out of money and pension obligations grow, we will increasingly see officials faced with a choice between protecting city workers or taxpayers. It’s not hard to understand why the politically powerful CalPERS is so confident that the demands of public employees always come first.

As the Stockton Record reported recently, CalPERS “dwarfs all other creditors with a $245 million liability in the city over the next decade. Yet National Public Finance Guarantee Corp., an insurer of several Stockton bonds, contends in its court papers that CalPERS is conspicuously missing from the list of those Stockton engaged in pre-bankruptcy negotiations … .”

That company argues persuasively that the city never had any intention to seek reduced payments from CalPERS. In bankruptcy, the company or city runs out of money and then the creditors fight it out. Here, it seems like city officials cherry-picked which debtors to stiff, which certainly backs the company’s case that Stockton officials have showed bias and that this is a distortion of the bankruptcy process.

While the bond markets aren’t yet spooked, they do have reason for concern given that pension debts are growing, and there are few other places to trim if public employee retirement plans are off the table. Even the feds are sounding some warning bells. As Bloomberg reported last month, “The U.S. Securities and Exchange Commission said it plans to seek power to force better disclosures from states and cities participating in the $3.7 trillion municipal-bond market.” They should add this disclosure: Your retirement investments will always lose out to public employee pension demands.

Those of us who have viewed Chapter 9 bankruptcy as a useful option to help troubled cities get their books in order have miscalculated. Public employee unions and their allies in the courts and the retirement systems are so powerful that even during dire financial circumstances, their selfish demands trump everything else. Although bankruptcy can be a good tool, as Orange County’s 1994 bankruptcy made clear, the process is no panacea for incorrigibly wasteful, union-controlled local governments.

The crisis is not going away, despite CalPERS’ insistence otherwise. Former Los Angeles Mayor Richard Riordan, for instance, said earlier in the week that the state’s largest city faces “disaster” if officials there don’t fix LA’s pension system.

We should closely watch the unfolding proceedings in bankruptcy court, as Stockton goes through this process. But the more significant battle is in San Jose, as courts determine whether voters’ support for a June pension reform measure that cuts pensions for existing workers is legal. The key there is the battle over cutting pensions for current workers, given that cuts to new hires only will not defuse the pension-debt time bomb.

If the courts side with reformers, there may be hope for rolling back pension costs and saving city services. If not, Californians better get ready for higher taxes and fewer municipal services, given that there are precious few options left. And without a reform path that touches pensions for existing workers, investors might want to rethink the long-term safety of their bond holdings, which will become an even bigger target.