"While plaintiff offered evidence that consumption of coffee increases the risk of harm to the fetus, to infants, to children and to adults, defendants' medical and epidemiology experts testified that they had no opinion on causation," Berle wrote in his proposed ruling. "Defendants failed to satisfy their burden of proving ... that consumption of coffee confers a benefit to human health."

Los Angeles Superior Court Judge Elihu Berle said Wednesday that the coffee makers hadn't presented the proper grounds at trial to prevail.

The Council for Education and Research on Toxics wanted the coffee industry to remove acrylamide from its processing — like potato chip makers did when it sued them years ago — or disclose the danger in ominous warning signs or labels. The industry, led by Starbucks Corp., said the level of the chemical in coffee isn't harmful and any risks are outweighed by benefits.

The culprit is a chemical produced in the bean roasting process that is a known carcinogen and has been at the heart of an eight-year legal struggle between a tiny nonprofit group and Big Coffee.

Scientists haven't rendered a verdict on whether coffee is good or bad for you but a California judge has. He says coffee sellers in the state should have to post cancer warnings.

The suit was brought against Starbucks and 90 companies under a controversial law passed by California voters in 1986 that has been credited with culling cancer-causing chemicals from myriad products and also criticized for leading to quick settlement shakedowns.

The Safe Drinking Water and Toxic Enforcement Act, better known as Proposition 65, requires warning labels for about 900 chemicals known to cause cancer or birth defects. It allows private citizens, advocacy groups and attorneys to sue on behalf of the state and collect a portion of civil penalties for failure to provide warnings.

"This lawsuit has made a mockery of Prop. 65, has confused consumers, and does nothing to improve public health," said William Murray, president and CEO of the National Coffee Association, who added that coffee had been shown to be a healthy beverage.

Scientific evidence on coffee has gone back and forth for a long time, but concerns have eased recently about possible dangers of coffee, with some studies finding health benefits.

In 2016, the cancer agency of the World Health Organization moved coffee off its "possible carcinogen" list.

Studies indicate coffee is unlikely to cause breast, prostate or pancreatic cancer, and it seems to lower the risks for liver and uterine cancers, the agency said. Evidence is inadequate to determine its effect on dozens of other cancer types.

Coffee companies have said it's not feasible to remove acrylamide from their product without ruining the flavor.

But attorney Raphael Metzger, who brought the lawsuit and drinks a few cups of coffee a day, said the industry could remove the chemical without impairing taste.

"I firmly believe if the potato chip industry can do it, so can the coffee industry," Metzger said. "A warning won't be that effective because it's an addictive product."

Many coffee shops have already posted warnings that say acrylamide is cancer-causing chemical found in coffee. But signs that are supposed to be posted at the point of sale are often found in places not easily visible, such as below the counter where cream and sugar are available.

Customers at shops that post warnings are often unaware or unconcerned about them.

Afternoon coffee drinkers at a Los Angeles Starbucks said they might look into the warning or give coffee drinking a second thought after the ruling, but the cup of joe was likely to win out.

"I just don't think it would stop me," said Jen Bitterman, a digital marketing technologist. "I love the taste, I love the ritual, I love the high, the energy, and I think I'm addicted to it."

Darlington Ibekwe, a lawyer in Los Angeles, said a cancer warning would be annoying but wouldn't stop him from treating himself to three lattes a week.

"It's like cigarettes. Like, damn, now I've got to see this?" he said. "Dude, I'm enjoying my coffee."

The defendants have a couple weeks to challenge the ruling before it is final and could seek relief from an appellate court.

If the ruling stands, it could come with a stiff financial penalty and could rattle consumers beyond state lines.

The judge can set another phase of trial to consider potential civil penalties up to $2,500 per person exposed each day over eight years. That could be an astronomical sum in a state with close to 40 million residents, though such a massive fine is unlikely.

California's outsized market could make it difficult to tailor packaging with warning labels specifically to stores in the state.

That means out-of-state coffee drinkers could also take their coffee with a cancer warning. Cream and sugar would still be optional.

WATCH: Here's why Starbucks failed in Australia