Commit a687d766 by Venkatesh Seetharam

BUG-38312 create class with empty name returns a 500

parent fee7c5cc
...@@ -52,13 +52,10 @@ import org.slf4j.LoggerFactory; ...@@ -52,13 +52,10 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import java.io.IOException; import java.util.LinkedHashSet;
import java.io.InputStream; import java.util.List;
import java.io.InputStreamReader; import java.util.Map;
import java.net.URL; import java.util.Set;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/** /**
* Simple wrapper over TypeSystem and MetadataRepository services with hooks * Simple wrapper over TypeSystem and MetadataRepository services with hooks
...@@ -136,13 +133,20 @@ public class DefaultMetadataService implements MetadataService { ...@@ -136,13 +133,20 @@ public class DefaultMetadataService implements MetadataService {
*/ */
@Override @Override
public JSONObject createType(String typeDefinition) throws MetadataException { public JSONObject createType(String typeDefinition) throws MetadataException {
try { ParamChecker.notEmpty(typeDefinition, "type definition cannot be empty");
ParamChecker.notEmpty(typeDefinition, "type definition cannot be empty");
TypesDef typesDef = TypesSerialization.fromJson(typeDefinition); TypesDef typesDef;
if(typesDef.isEmpty()) try {
typesDef = TypesSerialization.fromJson(typeDefinition);
if(typesDef.isEmpty()) {
throw new MetadataException("Invalid type definition"); throw new MetadataException("Invalid type definition");
}
} catch (Exception e) {
LOG.error("Unable to deserialize json={}", typeDefinition, e);
throw new IllegalArgumentException("Unable to deserialize json");
}
try {
final Map<String, IDataType> typesAdded = typeSystem.defineTypes(typesDef); final Map<String, IDataType> typesAdded = typeSystem.defineTypes(typesDef);
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment