Is throwing Workflow.wrap from a query method bad practive?

For the past 4 years I have had a query method that would throw an exception with Workflow.Wrap(). I was then able to catch the exception from my api where I called the query method using the java sdk. Today I am testing upgrading to a newer temporal version and I am seeing the querymethod retry after throwing the exception indefinitely until my server timesout. Has something changed that is causing this and do you have a suggestion to solve this?

Here is a simplified version of the querymethod

@QueryMethod
public Response queryMethod(){
   if(condition){
      return response;
   } 
   throw Workflow.wrap(new DetailedException);
}


Api
try{
   stub.queryMethod() //hangs here while the queryMethod retries forever
} catch(Exception e){
   // Use to return here right away
}

Thank you for your help

workflow update has replaced need to poll via workflow query