Skip to content

Commit ddf3777

Browse files
committed
fix(profile): reject unsafe shared interceptors
1 parent d71dd4f commit ddf3777

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
@@ -1100,6 +1100,12 @@ public HermesClient forProfile(ProfileBinding binding) {
11001100
if (!isHttpEnabled()) {
11011101
throw new IllegalStateException("Hermes HTTP client is disabled");
11021102
}
1103+
if (ownedHttpClient == null
1104+
&& (!sharedHttpClient.interceptors().isEmpty()
1105+
|| !sharedHttpClient.networkInterceptors().isEmpty())) {
1106+
throw new IllegalStateException(
1107+
"Cannot prove profile isolation for an externally managed OkHttpClient with interceptors");
1108+
}
11031109
String profileId = normalizeProfileId(binding.getProfileId());
11041110
String cacheKey = config.getHttp().getBaseUrl() + "|" + profileId + "|" + binding.getCredentialIdentity();
11051111
return profileClients.computeIfAbsent(cacheKey, ignored -> createProfileClient(binding, profileId));

0 commit comments

Comments
 (0)