[OLINGO-798] Fix potential nullpointer in client getContainerCase
This commit is contained in:
parent
9f663baf5c
commit
46cad03fed
|
@ -155,11 +155,18 @@ public class ClientCsdlEdmProvider extends CsdlAbstractEdmProvider {
|
|||
|
||||
@Override
|
||||
public CsdlEntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName)
|
||||
throws ODataException {
|
||||
throws ODataException {
|
||||
for (CsdlSchema schema : xmlSchemas.values()) {
|
||||
if (schema.getEntityContainer() != null) {
|
||||
return new CsdlEntityContainerInfo().setContainerName(entityContainerName).setExtendsContainer(
|
||||
schema.getEntityContainer().getExtendsContainerFQN());
|
||||
CsdlEntityContainer entityContainer = schema.getEntityContainer();
|
||||
if (entityContainer != null) {
|
||||
FullQualifiedName containerFQN;
|
||||
if (entityContainerName == null) {
|
||||
containerFQN = new FullQualifiedName(schema.getNamespace(), entityContainer.getName());
|
||||
} else {
|
||||
containerFQN = entityContainerName;
|
||||
}
|
||||
return new CsdlEntityContainerInfo().setContainerName(containerFQN).setExtendsContainer(
|
||||
entityContainer.getExtendsContainerFQN());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -196,6 +196,16 @@ public class MetadataTest extends AbstractTest {
|
|||
assertEquals("NorthwindEntities", entityContainer.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContainerWithoutCallingGetSchemas() {
|
||||
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
|
||||
toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
|
||||
|
||||
Edm edm = getClient().getReader().readMetadata(metadata.getSchemaByNsOrAlias());
|
||||
|
||||
assertNotNull(edm.getEntityContainer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Example 85 from CSDL specification.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue