Skip to content

Commit 1c8021f

Browse files
committed
Refactor the code and add javadoc
Signed-off-by: Shashwat Sharma <[email protected]>
1 parent ddb8939 commit 1c8021f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

common/src/main/java/io/pravega/schemaregistry/common/NameUtil.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.google.common.base.Strings;
1414

1515
public class NameUtil {
16-
private static final String DEFAULT_TYPE = "default_type";
16+
private static final String DEFAULT_TYPE = "default_namespace";
1717
/**
1818
* Extracts the name from the fully qualified type name. Name represents the last token after ".".
1919
* If the qualified name does not contain "." then the name is same as qualified name.
@@ -63,15 +63,17 @@ public static String qualifiedName(String qualifier, String name) {
6363

6464
/**
6565
* Type value if the 'type' is not null of empty.
66-
* If type is null or empty then the created name is simply 'namespace.groupName'.
66+
* If type is null or empty and the namespace is null or empty created name is 'default_namespace.groupName'.
67+
* If type is null or empty and namespace is not null or empty then created name is 'namespace.groupName'.
6768
*
6869
* @param type the value provided with API call (schemaInfo.getType()).
6970
* @param groupName the name of the group for schema
7071
* @param namespace the namespace for the schema
7172
* @return Provided name or Created name for type in SchemaInfo
7273
*/
7374
public static String createTypeIfAbsent(String type, String groupName, String namespace) {
74-
String nameSpace = Strings.isNullOrEmpty(namespace) ? DEFAULT_TYPE : namespace;
75-
return Strings.isNullOrEmpty(type) ? String.format("%s.%s", nameSpace, groupName) : type;
75+
Preconditions.checkNotNull(groupName, "Group can not be null");
76+
String typeName = Strings.isNullOrEmpty(namespace) ? DEFAULT_TYPE : namespace;
77+
return Strings.isNullOrEmpty(type) ? String.format("%s.%s", typeName, groupName) : type;
7678
}
7779
}

server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,6 @@ private boolean checkCompatibility(SchemaInfo schema, GroupProperties groupPrope
813813
}
814814

815815
private SchemaInfo normalizeSchemaBinary(SchemaInfo schemaInfo, String group, String namespace) {
816-
Preconditions.checkNotNull(group, "Group can not be null");
817816
// validates and the schema binary.
818817
ByteBuffer schemaBinary = schemaInfo.getSchemaData();
819818
boolean isValid = true;

server/src/main/java/io/pravega/schemaregistry/storage/impl/schemas/PravegaKeyValueSchemas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private CompletionStage<String> addNewSchemaRecord(SchemaInfo schemaInfo, Schema
134134
entries.put(KEY_SERIALIZER.toBytes(new SchemaIdChunkKey(id, i)),
135135
new VersionedRecord<>(bytes, null));
136136
}
137-
log.info("Calling update entries for new schema addition");
137+
log.trace("Call for update entries for new schema addition with schema {}", schemaInfo);
138138
return tableStore.updateEntries(SCHEMAS, entries)
139139
.thenApply(v -> id);
140140
}

0 commit comments

Comments
 (0)