File tree Expand file tree Collapse file tree 5 files changed +18
-21
lines changed Expand file tree Collapse file tree 5 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -1425,8 +1425,7 @@ public void TestGetHoldout_Integration()
1425
1425
Assert . AreEqual ( "global_holdout" , globalHoldout . Key ) ;
1426
1426
1427
1427
var invalidHoldout = datafileProjectConfig . GetHoldout ( "invalid_id" ) ;
1428
- Assert . IsNotNull ( invalidHoldout ) ;
1429
- Assert . AreEqual ( "" , invalidHoldout . Id ) ; // Dummy holdout has empty ID
1428
+ Assert . IsNull ( invalidHoldout ) ;
1430
1429
}
1431
1430
1432
1431
[ Test ]
@@ -1461,8 +1460,7 @@ public void TestMissingHoldoutsField_BackwardCompatibility()
1461
1460
Assert . AreEqual ( 0 , holdouts . Length ) ;
1462
1461
1463
1462
var holdout = datafileProjectConfig . GetHoldout ( "any_id" ) ;
1464
- Assert . IsNotNull ( holdout ) ;
1465
- Assert . AreEqual ( "" , holdout . Id ) ; // Dummy holdout has empty ID
1463
+ Assert . IsNull ( holdout ) ;
1466
1464
}
1467
1465
1468
1466
#endregion
Original file line number Diff line number Diff line change @@ -795,7 +795,7 @@ public Rollout GetRolloutFromId(string rolloutId)
795
795
/// Get the holdout from the ID
796
796
/// </summary>
797
797
/// <param name="holdoutId">ID for holdout</param>
798
- /// <returns>Holdout Entity corresponding to the holdout ID or a dummy entity if ID is invalid</returns>
798
+ /// <returns>Holdout Entity corresponding to the holdout ID or null if ID is invalid</returns>
799
799
public Holdout GetHoldout ( string holdoutId )
800
800
{
801
801
#if NET35 || NET40
@@ -804,7 +804,7 @@ public Holdout GetHoldout(string holdoutId)
804
804
if ( string . IsNullOrWhiteSpace ( holdoutId ) )
805
805
#endif
806
806
{
807
- return new Holdout ( ) ;
807
+ return null ;
808
808
}
809
809
810
810
if ( _HoldoutIdMap . ContainsKey ( holdoutId ) )
@@ -816,7 +816,7 @@ public Holdout GetHoldout(string holdoutId)
816
816
Logger . Log ( LogLevel . ERROR , message ) ;
817
817
ErrorHandler . HandleError (
818
818
new InvalidExperimentException ( "Provided holdout is not in datafile." ) ) ;
819
- return new Holdout ( ) ;
819
+ return null ;
820
820
}
821
821
822
822
/// <summary>
Original file line number Diff line number Diff line change @@ -28,15 +28,6 @@ namespace OptimizelySDK.Entity
28
28
/// </summary>
29
29
public class Holdout : IdKeyEntity , IExperimentCore
30
30
{
31
- /// <summary>
32
- /// Constructor that initializes properties to avoid null values
33
- /// </summary>
34
- public Holdout ( )
35
- {
36
- Id = "" ;
37
- Key = "" ;
38
- }
39
-
40
31
/// <summary>
41
32
/// Holdout status enumeration
42
33
/// </summary>
Original file line number Diff line number Diff line change @@ -322,7 +322,7 @@ public interface ProjectConfig
322
322
/// Get the holdout from the ID
323
323
/// </summary>
324
324
/// <param name="holdoutId">ID for holdout</param>
325
- /// <returns>Holdout Entity corresponding to the holdout ID or a dummy entity if ID is invalid</returns>
325
+ /// <returns>Holdout Entity corresponding to the holdout ID or null if ID is invalid</returns>
326
326
Holdout GetHoldout ( string holdoutId ) ;
327
327
328
328
/// <summary>
Original file line number Diff line number Diff line change @@ -120,17 +120,25 @@ public List<Holdout> GetHoldoutsForFlag(string flagId)
120
120
return _flagHoldoutCache [ flagId ] ;
121
121
122
122
var activeHoldouts = new List < Holdout > ( ) ;
123
-
124
123
// Start with global holdouts, excluding any that are specifically excluded for this flag
125
124
var excludedForFlag = _excludedHoldouts . ContainsKey ( flagId ) ? _excludedHoldouts [ flagId ] : new List < Holdout > ( ) ;
126
125
127
- foreach ( var globalHoldout in _globalHoldouts )
126
+ if ( excludedForFlag . Count > 0 )
128
127
{
129
- if ( ! excludedForFlag . Contains ( globalHoldout ) )
128
+ // Only iterate if we have exclusions to check
129
+ foreach ( var globalHoldout in _globalHoldouts )
130
130
{
131
- activeHoldouts . Add ( globalHoldout ) ;
131
+ if ( ! excludedForFlag . Contains ( globalHoldout ) )
132
+ {
133
+ activeHoldouts . Add ( globalHoldout ) ;
134
+ }
132
135
}
133
136
}
137
+ else
138
+ {
139
+ // No exclusions, add all global holdouts directly
140
+ activeHoldouts . AddRange ( _globalHoldouts ) ;
141
+ }
134
142
135
143
// Add included holdouts for this flag
136
144
if ( _includedHoldouts . ContainsKey ( flagId ) )
You can’t perform that action at this time.
0 commit comments