Skip to content

Commit b43a68e

Browse files
committed
fix(profile): reject unsafe shared interceptors
1 parent 47b10bd commit b43a68e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎src/main/java/io/github/easy4j/hermes/HermesClient.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,12 @@ public HermesClient forProfile(ProfileBinding binding) {
11031103
if (!isHttpEnabled()) {
11041104
throw new IllegalStateException("Hermes HTTP client is disabled");
11051105
}
1106+
if (ownedHttpClient == null
1107+
&& (!sharedHttpClient.interceptors().isEmpty()
1108+
|| !sharedHttpClient.networkInterceptors().isEmpty())) {
1109+
throw new IllegalStateException(
1110+
"Cannot prove profile isolation for an externally managed OkHttpClient with interceptors");
1111+
}
11061112
String profileId = normalizeProfileId(binding.getProfileId());
11071113
String cacheKey = config.getHttp().getBaseUrl() + "|" + profileId + "|" + binding.getCredentialIdentity();
11081114
return profileClients.computeIfAbsent(cacheKey, ignored -> createProfileClient(binding, profileId));

0 commit comments

Comments
 (0)