Skip to content

Commit 40e1633

Browse files
Merge branch '8.0.x' into 8.1.x by rayokota
2 parents 3d2a845 + 18b7f57 commit 40e1633

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
@@ -2324,14 +2324,24 @@ private CloseableIterator<SchemaRegistryValue> allVersionsFromAllContexts(
23242324
return new DelegatingIterator<>(versions.iterator());
23252325
}
23262326

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

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

23372347
public void clearNewSchemaCache() {

0 commit comments

Comments
 (0)