Skip to content

Commit a5de829

Browse files
committed
Fixed an issue where NullReferenceException was thrown when calling AddPartETags() on CompleteMultipartUploadRequest object.
1 parent 387686b commit a5de829

File tree

2 files changed

+62
-20
lines changed

2 files changed

+62
-20
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "S3",
5+
"type": "patch",
6+
"changeLogMessages": [ "Fixed an issue where NullReferenceException was thrown when calling AddPartETags() on CompleteMultipartUploadRequest object." ]
7+
}
8+
]
9+
}

sdk/src/Services/S3/Custom/Model/CompleteMultipartUploadRequest.cs

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,11 @@ public List<PartETag> PartETags
529529
/// <param name="partETags">PartETags that will added to this request.</param>
530530
public void AddPartETags(params PartETag[] partETags)
531531
{
532+
if (PartETags == null)
533+
{
534+
PartETags = new List<PartETag>();
535+
}
536+
532537
if (partETags != null)
533538
{
534539
foreach (PartETag part in partETags)
@@ -544,13 +549,17 @@ public void AddPartETags(params PartETag[] partETags)
544549
/// <param name="partETags">PartETags that will added to this request.</param>
545550
public void AddPartETags(IEnumerable<PartETag> partETags)
546551
{
547-
if (partETags == null)
552+
if (PartETags == null)
548553
{
549-
partETags = new List<PartETag>();
554+
PartETags = new List<PartETag>();
550555
}
551-
foreach (PartETag part in partETags)
556+
557+
if (partETags != null)
552558
{
553-
this.PartETags.Add(part);
559+
foreach (PartETag part in partETags)
560+
{
561+
this.PartETags.Add(part);
562+
}
554563
}
555564
}
556565

@@ -568,9 +577,12 @@ public void AddPartETags(params UploadPartResponse[] responses)
568577
PartETags = new List<PartETag>();
569578
}
570579

571-
foreach (UploadPartResponse response in responses)
580+
if (responses != null)
572581
{
573-
this.PartETags.Add(new PartETag(response, copyChecksums: false));
582+
foreach (UploadPartResponse response in responses)
583+
{
584+
this.PartETags.Add(new PartETag(response, copyChecksums: false));
585+
}
574586
}
575587
}
576588

@@ -588,9 +600,12 @@ public void AddPartETags(IEnumerable<UploadPartResponse> responses)
588600
PartETags = new List<PartETag>();
589601
}
590602

591-
foreach (UploadPartResponse response in responses)
603+
if (responses != null)
592604
{
593-
this.PartETags.Add(new PartETag(response, copyChecksums: false));
605+
foreach (UploadPartResponse response in responses)
606+
{
607+
this.PartETags.Add(new PartETag(response, copyChecksums: false));
608+
}
594609
}
595610
}
596611

@@ -605,9 +620,12 @@ public void AddPartETagsAndChecksums(params UploadPartResponse[] responses)
605620
PartETags = new List<PartETag>();
606621
}
607622

608-
foreach (UploadPartResponse response in responses)
623+
if (responses != null)
609624
{
610-
this.PartETags.Add(new PartETag(response, copyChecksums: true));
625+
foreach (UploadPartResponse response in responses)
626+
{
627+
this.PartETags.Add(new PartETag(response, copyChecksums: true));
628+
}
611629
}
612630
}
613631

@@ -622,9 +640,12 @@ public void AddPartETagsAndChecksums(IEnumerable<UploadPartResponse> responses)
622640
PartETags = new List<PartETag>();
623641
}
624642

625-
foreach (UploadPartResponse response in responses)
643+
if (responses != null)
626644
{
627-
this.PartETags.Add(new PartETag(response, copyChecksums: true));
645+
foreach (UploadPartResponse response in responses)
646+
{
647+
this.PartETags.Add(new PartETag(response, copyChecksums: true));
648+
}
628649
}
629650
}
630651

@@ -642,9 +663,12 @@ public void AddPartETags(params CopyPartResponse[] responses)
642663
PartETags = new List<PartETag>();
643664
}
644665

645-
foreach (CopyPartResponse response in responses)
666+
if (responses != null)
646667
{
647-
this.PartETags.Add(new PartETag(response, copyChecksums: false));
668+
foreach (CopyPartResponse response in responses)
669+
{
670+
this.PartETags.Add(new PartETag(response, copyChecksums: false));
671+
}
648672
}
649673
}
650674

@@ -662,9 +686,12 @@ public void AddPartETags(IEnumerable<CopyPartResponse> responses)
662686
PartETags = new List<PartETag>();
663687
}
664688

665-
foreach (CopyPartResponse response in responses)
689+
if (responses != null)
666690
{
667-
this.PartETags.Add(new PartETag(response, copyChecksums: false));
691+
foreach (CopyPartResponse response in responses)
692+
{
693+
this.PartETags.Add(new PartETag(response, copyChecksums: false));
694+
}
668695
}
669696
}
670697

@@ -679,9 +706,12 @@ public void AddPartETagsAndChecksums(params CopyPartResponse[] responses)
679706
PartETags = new List<PartETag>();
680707
}
681708

682-
foreach (CopyPartResponse response in responses)
709+
if (responses != null)
683710
{
684-
this.PartETags.Add(new PartETag(response, copyChecksums: true));
711+
foreach (CopyPartResponse response in responses)
712+
{
713+
this.PartETags.Add(new PartETag(response, copyChecksums: true));
714+
}
685715
}
686716
}
687717

@@ -696,9 +726,12 @@ public void AddPartETagsAndChecksums(IEnumerable<CopyPartResponse> responses)
696726
PartETags = new List<PartETag>();
697727
}
698728

699-
foreach (CopyPartResponse response in responses)
729+
if (responses != null)
700730
{
701-
this.PartETags.Add(new PartETag(response, copyChecksums: true));
731+
foreach (CopyPartResponse response in responses)
732+
{
733+
this.PartETags.Add(new PartETag(response, copyChecksums: true));
734+
}
702735
}
703736
}
704737

0 commit comments

Comments
 (0)