#vulnerable code 
                                public Query createQueryWithParams(String queryText, Object... paramValues){
        return createQuery(queryText, null)
                .withParams(paramValues);
    } 
                            #location 3 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public Query createQueryWithParams(String queryText, Object... paramValues){
        Query query = createQuery(queryText, null);
        boolean destroy = true;
        try {
            query.withParams(paramValues);
            destroy = false;
            return query;
        } finally {
            // instead of re-wrapping exception
            // just keep it as-is
            // but kill a query
            if(destroy) query.close();
        }
    }