How do I modify a Jira issue's resolution using the Jira REST Java client?

I use the Jira REST Java client to update an issue’s resolution upon closure. The streamlined code below offers an alternate method:

public class ResolutionModifier {
    public static void main(String[] args) {
        JiraIssue currentIssue = client.fetchIssue("BUG-101");
        Transition trans = client.findTransition(currentIssue, "Completed");
        client.applyTransition(currentIssue, trans, "Resolution updated");
    }
}

Based on my experience, working with the Jira REST Java client to modify an issue’s resolution involves more than simply applying a transition. In one project, I encountered a problem where the resolution field did not update reliably until I explicitly set it in the same API call as the transition. This meant that after fetching the issue, I used a custom field update method to assign the new resolution value before committing the transition. This approach helps to avoid any unexpected behaviors that sometimes arise from using separate calls. It’s essential to log the changes and verify the update right after the operation, ensuring consistency across all modifications.