Officer William Porter, right, arrives at Courthouse East with his attorneys Wednesday, Jan. 6, 2016, in Baltimore. Circuit Judge Barry Williams is holding a motions hearing Wednesday ahead of the trial for Caesar Goodson, who drove the police transport van where Freddie Gray was critically injured. Prosecutors want Porter, whose trial ended in a mistrial last month, to testify against Goodson and Sgt. Alicia White. (Jerry Jackson/The Baltimore Sun via AP)  WASHINGTON EXAMINER OUT; MANDATORY CREDIT

Officer William Porter, right, arrives at Courthouse East with his attorneys Wednesday, Jan. 6, 2016, in Baltimore. Circuit Judge Barry Williams is holding a motions hearing Wednesday ahead of the trial for Caesar Goodson, who drove the police transport van where Freddie Gray was critically injured. Prosecutors want Porter, whose trial ended in a mistrial last month, to testify against Goodson and Sgt. Alicia White. (Jerry Jackson/The Baltimore Sun via AP)

BALTIMORE (AP) — A Baltimore judge has ruled that a police officer facing charges stemming from the death of Freddie Gray must testify against his fellow officer at an upcoming trial.

Baltimore Circuit Judge Barry Williams ruled Wednesday that William Porter, whose trial ended in a mistrial last month, can be compelled to take the stand in the trial of wagon driver Caesar Goodson. Goodson is facing the most serious charge of the six officers charged in the case.

Caesar Goodson, right, arrives at Courthouse East on Wednesday, Jan. 6, 2016, in Baltimore. Circuit Judge Barry Williams is holding a motions hearing Wednesday ahead of the trial for Goodson, who drove the police transport van where Freddie Gray was critically injured. Prosecutors want William Porter, whose trial ended in a mistrial last month, to testify against Goodson and Sgt. Alicia White. (Kim Hairston/The Baltimore Sun via AP)  WASHINGTON EXAMINER OUT; MANDATORY CREDIT

Caesar Goodson, right, arrives at Courthouse East on Wednesday, Jan. 6, 2016, in Baltimore. Circuit Judge Barry Williams is holding a motions hearing Wednesday ahead of the trial for Goodson, who drove the police transport van where Freddie Gray was critically injured. Prosecutors want William Porter, whose trial ended in a mistrial last month, to testify against Goodson and Sgt. Alicia White. (Kim Hairston/The Baltimore Sun via AP)

Porter had previously said he planned to invoke his Fifth Amendment right against self-incrimination if called to the stand. Now, if he does, he can be held in contempt of court.

Porter’s attorney Gary Proctor says he plans to ask an appeals court to overturn the ruling before Monday, when Goodson’s trial is scheduled to begin.