Skip to content

Commit 579d09e

Browse files
Merge branch '8.1.x' into master by rayokota
2 parents 6049e89 + 40e1633 commit 579d09e

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

client/src/main/java/io/confluent/kafka/schemaregistry/client/rest/entities/Schema.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ public Schema copy(Integer version, Integer id) {
259259
}
260260

261261
public Schema toHashKey() {
262-
return new Schema(subject, null, null, schemaType, references, metadata, ruleSet, schema);
262+
// Deep copy the references list if it's not null
263+
List<SchemaReference> referencesCopy = references != null
264+
? references.stream()
265+
.map(SchemaReference::copy)
266+
.collect(Collectors.toList())
267+
: null;
268+
269+
return new Schema(subject, null, null, schemaType, referencesCopy, metadata, ruleSet, schema);
263270
}
264271

265272
@io.swagger.v3.oas.annotations.media.Schema(description = SUBJECT_DESC, example = SUBJECT_EXAMPLE)

core/src/main/java/io/confluent/kafka/schemaregistry/storage/KafkaSchemaRegistry.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,14 +2323,24 @@ private CloseableIterator<SchemaRegistryValue> allVersionsFromAllContexts(
23232323
return new DelegatingIterator<>(versions.iterator());
23242324
}
23252325

2326-
public void invalidateFromNewSchemaCache(Schema schema) {
2327-
newSchemaCache.invalidate(new RawSchema(schema, true, false));
2328-
newSchemaCache.invalidate(new RawSchema(schema, true, true));
2326+
/**
2327+
* Invalidate the cached parsed schema for a new schema.
2328+
*
2329+
* @param schemaKey a schema key obtained by {@link Schema#toHashKey()}
2330+
*/
2331+
public void invalidateFromNewSchemaCache(Schema schemaKey) {
2332+
newSchemaCache.invalidate(new RawSchema(schemaKey, true, false));
2333+
newSchemaCache.invalidate(new RawSchema(schemaKey, true, true));
23292334
}
23302335

2331-
public void invalidateFromOldSchemaCache(Schema schema) {
2332-
oldSchemaCache.invalidate(new RawSchema(schema, false, false));
2333-
oldSchemaCache.invalidate(new RawSchema(schema, false, true));
2336+
/**
2337+
* Invalidate the cached parsed schema for an old schema.
2338+
*
2339+
* @param schemaKey a schema key obtained by {@link Schema#toHashKey()}
2340+
*/
2341+
public void invalidateFromOldSchemaCache(Schema schemaKey) {
2342+
oldSchemaCache.invalidate(new RawSchema(schemaKey, false, false));
2343+
oldSchemaCache.invalidate(new RawSchema(schemaKey, false, true));
23342344
}
23352345

23362346
public void clearNewSchemaCache() {

0 commit comments

Comments
 (0)