@@ -649,7 +649,7 @@ func (s *IssueService) Get(issueID string, options *GetQueryOptions) (*Issue, *R
649649// DownloadAttachmentWithContext returns a Response of an attachment for a given attachmentID.
650650// The attachment is in the Response.Body of the response.
651651// This is an io.ReadCloser.
652- // The caller should close the resp.Body.
652+ // Caller must close resp.Body.
653653func (s * IssueService ) DownloadAttachmentWithContext (ctx context.Context , attachmentID string ) (* Response , error ) {
654654 apiEndpoint := fmt .Sprintf ("secure/attachment/%s/" , attachmentID )
655655 req , err := s .client .NewRequestWithContext (ctx , "GET" , apiEndpoint , nil )
@@ -667,6 +667,7 @@ func (s *IssueService) DownloadAttachmentWithContext(ctx context.Context, attach
667667}
668668
669669// DownloadAttachment wraps DownloadAttachmentWithContext using the background context.
670+ // Caller must close resp.Body
670671func (s * IssueService ) DownloadAttachment (attachmentID string ) (* Response , error ) {
671672 return s .DownloadAttachmentWithContext (context .Background (), attachmentID )
672673}
@@ -715,6 +716,7 @@ func (s *IssueService) PostAttachment(issueID string, r io.Reader, attachmentNam
715716}
716717
717718// DeleteAttachmentWithContext deletes an attachment of a given attachmentID
719+ // Caller must close resp.Body
718720func (s * IssueService ) DeleteAttachmentWithContext (ctx context.Context , attachmentID string ) (* Response , error ) {
719721 apiEndpoint := fmt .Sprintf ("rest/api/2/attachment/%s" , attachmentID )
720722
@@ -733,11 +735,13 @@ func (s *IssueService) DeleteAttachmentWithContext(ctx context.Context, attachme
733735}
734736
735737// DeleteAttachment wraps DeleteAttachmentWithContext using the background context.
738+ // Caller must close resp.Body
736739func (s * IssueService ) DeleteAttachment (attachmentID string ) (* Response , error ) {
737740 return s .DeleteAttachmentWithContext (context .Background (), attachmentID )
738741}
739742
740743// DeleteLinkWithContext deletes a link of a given linkID
744+ // Caller must close resp.Body
741745func (s * IssueService ) DeleteLinkWithContext (ctx context.Context , linkID string ) (* Response , error ) {
742746 apiEndpoint := fmt .Sprintf ("rest/api/2/issueLink/%s" , linkID )
743747
@@ -756,6 +760,7 @@ func (s *IssueService) DeleteLinkWithContext(ctx context.Context, linkID string)
756760}
757761
758762// DeleteLink wraps DeleteLinkWithContext using the background context.
763+ // Caller must close resp.Body
759764func (s * IssueService ) DeleteLink (linkID string ) (* Response , error ) {
760765 return s .DeleteLinkWithContext (context .Background (), linkID )
761766}
@@ -844,6 +849,7 @@ func (s *IssueService) Create(issue *Issue) (*Issue, *Response, error) {
844849// while also specifying query params. The issue is found by key.
845850//
846851// Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
852+ // Caller must close resp.Body
847853func (s * IssueService ) UpdateWithOptionsWithContext (ctx context.Context , issue * Issue , opts * UpdateQueryOptions ) (* Issue , * Response , error ) {
848854 apiEndpoint := fmt .Sprintf ("rest/api/2/issue/%v" , issue .Key )
849855 url , err := addOptions (apiEndpoint , opts )
@@ -867,6 +873,7 @@ func (s *IssueService) UpdateWithOptionsWithContext(ctx context.Context, issue *
867873}
868874
869875// UpdateWithOptions wraps UpdateWithOptionsWithContext using the background context.
876+ // Caller must close resp.Body
870877func (s * IssueService ) UpdateWithOptions (issue * Issue , opts * UpdateQueryOptions ) (* Issue , * Response , error ) {
871878 return s .UpdateWithOptionsWithContext (context .Background (), issue , opts )
872879}
@@ -886,6 +893,7 @@ func (s *IssueService) Update(issue *Issue) (*Issue, *Response, error) {
886893// UpdateIssueWithContext updates an issue from a JSON representation. The issue is found by key.
887894//
888895// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue
896+ // Caller must close resp.Body
889897func (s * IssueService ) UpdateIssueWithContext (ctx context.Context , jiraID string , data map [string ]interface {}) (* Response , error ) {
890898 apiEndpoint := fmt .Sprintf ("rest/api/2/issue/%v" , jiraID )
891899 req , err := s .client .NewRequestWithContext (ctx , "PUT" , apiEndpoint , data )
@@ -903,6 +911,7 @@ func (s *IssueService) UpdateIssueWithContext(ctx context.Context, jiraID string
903911}
904912
905913// UpdateIssue wraps UpdateIssueWithContext using the background context.
914+ // Caller must close resp.Body
906915func (s * IssueService ) UpdateIssue (jiraID string , data map [string ]interface {}) (* Response , error ) {
907916 return s .UpdateIssueWithContext (context .Background (), jiraID , data )
908917}
@@ -976,6 +985,7 @@ func (s *IssueService) DeleteCommentWithContext(ctx context.Context, issueID, co
976985 jerr := NewJiraError (resp , err )
977986 return jerr
978987 }
988+ defer resp .Body .Close ()
979989
980990 return nil
981991}
@@ -1052,6 +1062,7 @@ func (s *IssueService) UpdateWorklogRecord(issueID, worklogID string, record *Wo
10521062// AddLinkWithContext adds a link between two issues.
10531063//
10541064// Jira API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issueLink
1065+ // Caller must close resp.Body
10551066func (s * IssueService ) AddLinkWithContext (ctx context.Context , issueLink * IssueLink ) (* Response , error ) {
10561067 apiEndpoint := "rest/api/2/issueLink"
10571068 req , err := s .client .NewRequestWithContext (ctx , "POST" , apiEndpoint , issueLink )
@@ -1068,6 +1079,7 @@ func (s *IssueService) AddLinkWithContext(ctx context.Context, issueLink *IssueL
10681079}
10691080
10701081// AddLink wraps AddLinkWithContext using the background context.
1082+ // Caller must close resp.Body
10711083func (s * IssueService ) AddLink (issueLink * IssueLink ) (* Response , error ) {
10721084 return s .AddLinkWithContext (context .Background (), issueLink )
10731085}
@@ -1259,6 +1271,7 @@ func (s *IssueService) DoTransition(ticketID, transitionID string) (*Response, e
12591271// When performing the transition you can update or set other issue fields.
12601272//
12611273// Jira API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-doTransition
1274+ // Caller must close resp.Body
12621275func (s * IssueService ) DoTransitionWithPayloadWithContext (ctx context.Context , ticketID , payload interface {}) (* Response , error ) {
12631276 apiEndpoint := fmt .Sprintf ("rest/api/2/issue/%s/transitions" , ticketID )
12641277
@@ -1276,6 +1289,7 @@ func (s *IssueService) DoTransitionWithPayloadWithContext(ctx context.Context, t
12761289}
12771290
12781291// DoTransitionWithPayload wraps DoTransitionWithPayloadWithContext using the background context.
1292+ // Caller must close resp.Body
12791293func (s * IssueService ) DoTransitionWithPayload (ticketID , payload interface {}) (* Response , error ) {
12801294 return s .DoTransitionWithPayloadWithContext (context .Background (), ticketID , payload )
12811295}
@@ -1360,6 +1374,7 @@ func InitIssueWithMetaAndFields(metaProject *MetaProject, metaIssuetype *MetaIss
13601374}
13611375
13621376// DeleteWithContext will delete a specified issue.
1377+ // Caller must close resp.Body
13631378func (s * IssueService ) DeleteWithContext (ctx context.Context , issueID string ) (* Response , error ) {
13641379 apiEndpoint := fmt .Sprintf ("rest/api/2/issue/%s" , issueID )
13651380
@@ -1378,6 +1393,7 @@ func (s *IssueService) DeleteWithContext(ctx context.Context, issueID string) (*
13781393}
13791394
13801395// Delete wraps DeleteWithContext using the background context.
1396+ // Caller must close resp.Body
13811397func (s * IssueService ) Delete (issueID string ) (* Response , error ) {
13821398 return s .DeleteWithContext (context .Background (), issueID )
13831399}
@@ -1422,6 +1438,7 @@ func (s *IssueService) GetWatchers(issueID string) (*[]User, *Response, error) {
14221438// AddWatcherWithContext adds watcher to the given issue
14231439//
14241440// Jira API docs: https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-addWatcher
1441+ // Caller must close resp.Body
14251442func (s * IssueService ) AddWatcherWithContext (ctx context.Context , issueID string , userName string ) (* Response , error ) {
14261443 apiEndPoint := fmt .Sprintf ("rest/api/2/issue/%s/watchers" , issueID )
14271444
@@ -1439,13 +1456,15 @@ func (s *IssueService) AddWatcherWithContext(ctx context.Context, issueID string
14391456}
14401457
14411458// AddWatcher wraps AddWatcherWithContext using the background context.
1459+ // Caller must close resp.Body
14421460func (s * IssueService ) AddWatcher (issueID string , userName string ) (* Response , error ) {
14431461 return s .AddWatcherWithContext (context .Background (), issueID , userName )
14441462}
14451463
14461464// RemoveWatcherWithContext removes given user from given issue
14471465//
14481466// Jira API docs: https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-removeWatcher
1467+ // Caller must close resp.Body
14491468func (s * IssueService ) RemoveWatcherWithContext (ctx context.Context , issueID string , userName string ) (* Response , error ) {
14501469 apiEndPoint := fmt .Sprintf ("rest/api/2/issue/%s/watchers" , issueID )
14511470
@@ -1463,13 +1482,15 @@ func (s *IssueService) RemoveWatcherWithContext(ctx context.Context, issueID str
14631482}
14641483
14651484// RemoveWatcher wraps RemoveWatcherWithContext using the background context.
1485+ // Caller must close resp.Body
14661486func (s * IssueService ) RemoveWatcher (issueID string , userName string ) (* Response , error ) {
14671487 return s .RemoveWatcherWithContext (context .Background (), issueID , userName )
14681488}
14691489
14701490// UpdateAssigneeWithContext updates the user assigned to work on the given issue
14711491//
14721492// Jira API docs: https://docs.atlassian.com/software/jira/docs/api/REST/7.10.2/#api/2/issue-assign
1493+ // Caller must close resp.Body
14731494func (s * IssueService ) UpdateAssigneeWithContext (ctx context.Context , issueID string , assignee * User ) (* Response , error ) {
14741495 apiEndPoint := fmt .Sprintf ("rest/api/2/issue/%s/assignee" , issueID )
14751496
@@ -1487,6 +1508,7 @@ func (s *IssueService) UpdateAssigneeWithContext(ctx context.Context, issueID st
14871508}
14881509
14891510// UpdateAssignee wraps UpdateAssigneeWithContext using the background context.
1511+ // Caller must close resp.Body
14901512func (s * IssueService ) UpdateAssignee (issueID string , assignee * User ) (* Response , error ) {
14911513 return s .UpdateAssigneeWithContext (context .Background (), issueID , assignee )
14921514}
@@ -1520,6 +1542,7 @@ func (s *IssueService) GetRemoteLinksWithContext(ctx context.Context, id string)
15201542}
15211543
15221544// GetRemoteLinks wraps GetRemoteLinksWithContext using the background context.
1545+ // Caller must close resp.Body
15231546func (s * IssueService ) GetRemoteLinks (id string ) (* []RemoteLink , * Response , error ) {
15241547 return s .GetRemoteLinksWithContext (context .Background (), id )
15251548}
0 commit comments