@@ -89,7 +89,7 @@ void dynamicSelectorMissMustNotBeCached(final String paramType) {
8989 BaseDataCache .getInstance ().cacheSelectData (dynamic );
9090
9191 execute (false );
92- assertNull (MatchDataCache .getInstance ().obtainSelectorData (PLUGIN , "/x" ));
92+ assertNull (MatchDataCache .getInstance ().obtainSelectorData (PLUGIN , selectorCacheKey () ));
9393 assertNull (plugin .selector );
9494
9595 execute (true );
@@ -105,7 +105,7 @@ void dynamicRuleMissMustNotBeCached(final String paramType) {
105105 BaseDataCache .getInstance ().cacheRuleData (dynamic );
106106
107107 execute (false );
108- assertNull (MatchDataCache .getInstance ().obtainRuleData (PLUGIN , "/x" ));
108+ assertNull (MatchDataCache .getInstance ().obtainRuleData (PLUGIN , ruleCacheKey ( "selector" ) ));
109109 assertNull (plugin .rule );
110110
111111 execute (true );
@@ -126,7 +126,9 @@ void ruleMissMustNotBeCachedAcrossDynamicSelectors() {
126126 BaseDataCache .getInstance ().cacheRuleData (secondRule );
127127
128128 execute (true );
129- assertNull (MatchDataCache .getInstance ().obtainRuleData (PLUGIN , "/x" ));
129+ RuleData firstRuleMiss = MatchDataCache .getInstance ().obtainRuleData (PLUGIN , ruleCacheKey ("first" ));
130+ assertNotNull (firstRuleMiss );
131+ assertNull (firstRuleMiss .getId ());
130132
131133 execute (false );
132134 assertSame (secondRule , plugin .rule );
@@ -145,7 +147,7 @@ void timedSelectorMissMustNotBeCached(final String operator) {
145147
146148 clock .set (predicateFalse (operator , boundary ));
147149 execute (false );
148- assertNull (MatchDataCache .getInstance ().obtainSelectorData (PLUGIN , "/x" ));
150+ assertNull (MatchDataCache .getInstance ().obtainSelectorData (PLUGIN , selectorCacheKey () ));
149151 assertNull (plugin .selector );
150152
151153 clock .set (predicateTrue (operator , boundary ));
@@ -169,7 +171,7 @@ void timedRuleMissMustNotBeCached(final String operator) {
169171
170172 clock .set (predicateFalse (operator , boundary ));
171173 execute (false );
172- assertNull (MatchDataCache .getInstance ().obtainRuleData (PLUGIN , "/x" ));
174+ assertNull (MatchDataCache .getInstance ().obtainRuleData (PLUGIN , ruleCacheKey ( "selector" ) ));
173175 assertNull (plugin .rule );
174176
175177 clock .set (predicateTrue (operator , boundary ));
@@ -184,7 +186,7 @@ void pathOnlySelectorMissStillCaches() {
184186
185187 execute (false );
186188
187- SelectorData cached = MatchDataCache .getInstance ().obtainSelectorData (PLUGIN , "/x" );
189+ SelectorData cached = MatchDataCache .getInstance ().obtainSelectorData (PLUGIN , selectorCacheKey () );
188190 assertNotNull (cached );
189191 assertNull (cached .getId ());
190192 }
@@ -196,7 +198,7 @@ void pathOnlyRuleMissStillCaches() {
196198
197199 execute (false );
198200
199- RuleData cached = MatchDataCache .getInstance ().obtainRuleData (PLUGIN , "/x" );
201+ RuleData cached = MatchDataCache .getInstance ().obtainRuleData (PLUGIN , ruleCacheKey ( "selector" ) );
200202 assertNotNull (cached );
201203 assertNull (cached .getId ());
202204 }
@@ -209,6 +211,14 @@ private LocalDateTime predicateTrue(final String operator, final LocalDateTime b
209211 return "TimeAfter" .equals (operator ) ? boundary .plusSeconds (1 ) : boundary .minusSeconds (1 );
210212 }
211213
214+ private String selectorCacheKey () {
215+ return BaseDataCache .getInstance ().getVersion () + ":/x" ;
216+ }
217+
218+ private String ruleCacheKey (final String selectorId ) {
219+ return selectorId .length () + ":" + selectorId + selectorCacheKey ();
220+ }
221+
212222 private void execute (final boolean dynamicPresent ) {
213223 plugin .execute (MockServerWebExchange .from (MockServerHttpRequest .method (dynamicPresent ? HttpMethod .POST : HttpMethod .GET ,
214224 dynamicPresent ? "/x?tenant=a" : "/x?tenant=b" ).header ("X-Tenant" , dynamicPresent ? "a" : "b" )), exchange -> Mono .empty ()).block ();
0 commit comments