SAN FRANCISCO (CBS SF) — A judge has condemned an ongoing sting operation targeting gay men at public restrooms in Long Beach, in what appears to be the latest evidence of homophobia in California’s police departments.

On Friday, Los Angeles County Superior Court Judge Halim Dhanidina threw out lewd conduct and indecent exposure charges against a Long Beach resident, Rory Moroney, that stemmed from an October 2014 incident in which he allegedly exposed himself to an undercover Long Beach police officer at Recreation Park.

READ MORE: UPDATE: Atmospheric River: I-880 Shutdown, Flooded Roadways, Damaged Homes, Massive Rockslides In Storm's Wake

Bay Area lawyer Bruce Nickerson is Moroney’s defense attorney and has won similar cases against other California police departments, including San Leandro police, that have used decoys in lewd conduct stings targeted at gay men.

Nickerson has previously sued the city of Manhattan Beach for arrests its officers made during a sting operation targeting gay men in a beach bathroom in 2012. The city settled that lawsuit in 2014.

Nickerson has been fighting these types of stings for decades now. In 1996, he won a unanimous decision in 1996 from the California Supreme Court, which ruled that Mountain View police discriminated against gay men while conducting lewd conduct stings.

On Friday, the judge sided with Nickerson, stating that the Long Beach Police Department had practiced discrimination when its officers staged lewd conduct stings using only male officers as undercover decoys.

“This judge knows discrimination when he sees it,” Nickerson said. “His ruling is powerful because it sends a message far beyond this case. It sends a message to police departments throughout the state who do these decoy operations for lewd-conduct cases.”

The Long Beach stings, Dhanidina said, unfairly targeted homosexuals and caused the crimes to occur. He said the lewd conduct stings targeted only gay men and resulted in 55 arrests over a two-year period.

READ MORE: Atmospheric River: High Winds Topple Trees, Scaffolding in San Francisco

The Long Beach Police Department released a statement following the ruling stating,”All Long Beach Police Department employees are trained to police without bias, and do not discriminate based on sexual orientation or gender when responding to investigations or complaints.”

Long Beach police Chief Robert Luna said his department understands the seriousness of this ruling and “will evaluate how we document and track community complaints and will continue to reach out to other law enforcement agencies to identify strategies and best practices. We have a strong working relationship with our LGBTQ leaders and will be meeting with them to discuss their concerns.”

Luna said that the department is committed to civil rights and equality.

The San Francisco Police Department is also grappling with the fallout over a homophobic slurs by police officers. Offensive text messages exchanged by some members of the department and have been uncovered in recent months expressing homophobic and racist sentiments.

San Francisco Police Chief Greg Suhr said in a statement Monday, “On the behalf of the right-minded, upstanding members of the San Francisco Police Department, we will cut out this cancer of intolerance, and continue working hard every day to restore the trust of the City and the people we are privileged to serve.”

All San Francisco police officers will be required to complete anti-bias training.

Los Angeles County Sheriff Jim McDonnell released a statement Sunday explaining that he “very recently” learned Los Angeles County Sheriff’s Department Chief of Staff Tom Angel “shared inappropriate and unprofessional e-mails with others, during his service as Burbank Police Department Assistant Chief.” Engel’s emails included racist and sexist content. He has since resigned from the Los Angeles County Sheriff’s Department.

MORE NEWS: Atmospheric River: Parts of San Mateo County Pummeled with Heavy Rain, Flooding

By Hannah Albarazi – Follow her on Twitter: @hannahalbarazi.