You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (JIRA)" <ji...@apache.org> on 2016/02/08 23:59:40 UTC

[jira] [Closed] (SLING-5257) [TESTING][JCR MOCK] MockProperty getType generates java.lang.ArrayIndexOutOfBoundsException when the underlying array value is empty

     [ https://issues.apache.org/jira/browse/SLING-5257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert closed SLING-5257.
---------------------------------

> [TESTING][JCR MOCK] MockProperty getType generates java.lang.ArrayIndexOutOfBoundsException when the underlying array value is empty
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-5257
>                 URL: https://issues.apache.org/jira/browse/SLING-5257
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing JCR Mock 1.1.10
>            Reporter: Guillaume Douillet
>            Assignee: Stefan Seifert
>             Fix For: Testing JCR Mock 1.1.12
>
>
> Hello,
> When the underlying property value is an empty array, calling {{MockProperty.getType}} generates an {{java.lang.ArrayIndexOutOfBoundsException}}.
> Here a small test case exhibiting this behavior (to put in {{org.apache.sling.testing.mock.jcr.MockPropertyTest}}) :
> {code}
>    @Test
>     public void testEmptyArrayGetType() throws RepositoryException {
>         this.node1.setProperty("prop1", new Value[] {});
>         Property prop1 = this.node1.getProperty("prop1");
>         assertTrue(prop1.isMultiple());
>         assertEquals(PropertyType.UNDEFINED, prop1.getType());
>     }
> {code}
> A fix could be to return {{PropertyType.UNDEFINED}} when the underlying array value is empty :
>  {code}
>     @Override
>     public int getType() throws RepositoryException {
>     	if (this.itemData.getValues().length>0)
>     	{
>     		return this.itemData.getValues()[0].getType();
>     	}
>     	else
>     	{
>     		return PropertyType.UNDEFINED;
>     	}
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)