Skip to content

Commit c28aff2

Browse files
Merge branch '8.1.x' into master by Nitss10
2 parents ab4b963 + 65f99ee commit c28aff2

File tree

3 files changed

+3
-42
lines changed

3 files changed

+3
-42
lines changed

core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/SubjectsResource.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void lookUpSchemaUnderSubject(
124124
subject, lookupDeletedSchema, request.getSchemaType());
125125

126126
subject = QualifiedSubject.normalize(schemaRegistry.tenant(), subject);
127+
127128
// returns version if the schema exists. Otherwise returns 404
128129
Schema schema = new Schema(subject, request);
129130
io.confluent.kafka.schemaregistry.client.rest.entities.Schema matchingSchema;
@@ -133,15 +134,6 @@ public void lookUpSchemaUnderSubject(
133134
}
134135
matchingSchema = schemaRegistry.lookUpSchemaUnderSubjectUsingContexts(
135136
subject, schema, normalize, lookupDeletedSchema);
136-
137-
// If first attempt failed with normalize=false, try again with normalize=true
138-
if (matchingSchema == null && !normalize) {
139-
log.debug("No matching schema found with normalize = false,"
140-
+ " retrying with normalize = true");
141-
matchingSchema = schemaRegistry.lookUpSchemaUnderSubjectUsingContexts(
142-
subject, schema, true, lookupDeletedSchema);
143-
}
144-
145137
if (matchingSchema == null) {
146138
if (!schemaRegistry.hasSubjects(subject, lookupDeletedSchema)) {
147139
throw Errors.subjectNotFoundException(subject);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ Set<String> subjects(String subject, boolean lookupDeletedSubjects) throws
257257
void deleteSubjectMode(String subject) throws SchemaRegistryStoreException,
258258
OperationNotPermittedException;
259259

260+
RuleSetHandler getRuleSetHandler();
261+
260262
void setRuleSetHandler(RuleSetHandler ruleSetHandler);
261263

262264
HostnameVerifier getHostnameVerifier() throws SchemaRegistryStoreException;

core/src/test/java/io/confluent/kafka/schemaregistry/rest/RestApiTest.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,39 +1422,6 @@ public void testSchemaNormalization() throws Exception {
14221422
assertTrue(!messages.isEmpty() && messages.get(0).contains("Invalid schema"));
14231423
}
14241424

1425-
@Test
1426-
public void testLookUpSchemaWithNormalizationRetry() throws Exception {
1427-
String subject = "testSubject";
1428-
1429-
String schemaString1 = "{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"email4\",\"type\":\"string\"}]}";
1430-
1431-
// Register the original schema
1432-
TestUtils.registerAndVerifySchema(restApp.restClient, schemaString1, 1, subject);
1433-
1434-
// Same schema with different field ordering (semantically equivalent)
1435-
String schemaString2 = "{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"type\":\"int\",\"name\":\"id\"},{\"type\":\"string\",\"name\":\"email4\"}]}";
1436-
1437-
RegisterSchemaRequest request = new RegisterSchemaRequest();
1438-
request.setSchema(schemaString2);
1439-
1440-
io.confluent.kafka.schemaregistry.client.rest.entities.Schema schema =
1441-
restApp.restClient.lookUpSubjectVersion(request, subject, false, false);
1442-
assertNotNull(schema);
1443-
assertEquals(1, schema.getVersion().intValue());
1444-
1445-
// Different schema with different field name (not semantically equivalent)
1446-
String invalidSchema = "{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"type\":\"int\",\"name\":\"id\"},{\"type\":\"string\",\"name\":\"email6\"}]}";
1447-
request.setSchema(invalidSchema);
1448-
1449-
// Should fail since schemas are actually different
1450-
try {
1451-
restApp.restClient.lookUpSubjectVersion(request, subject, true, false);
1452-
fail("Should fail as schemas are not semantically equivalent");
1453-
} catch (RestClientException e) {
1454-
assertEquals(Errors.SCHEMA_NOT_FOUND_ERROR_CODE, e.getErrorCode());
1455-
}
1456-
}
1457-
14581425
@Test
14591426
public void testBad() throws Exception {
14601427
String subject1 = "testTopic1";

0 commit comments

Comments
 (0)