mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALF-20173 Alfresco TAGS Exceptions: java.lang.ArrayIndexOutOfBoundsException: 1
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@56190 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1188,14 +1188,41 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
while (nextLine != null)
|
||||
{
|
||||
String[] values = nextLine.split("\\" + TAG_DETAILS_DELIMITER);
|
||||
if(values.length == 1)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("No count for tag "+values[0]);
|
||||
}
|
||||
}
|
||||
else if (values.length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
result.add(new TagDetailsImpl(values[0], Integer.parseInt(values[1])));
|
||||
if(values.length > 2)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Ignoring extra guff for tag: " + values[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException nfe)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Invalid tag count for " + values[0] + "<"+values[1]+">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nextLine = reader.readLine();
|
||||
}
|
||||
}
|
||||
catch (IOException exception)
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to read tag details", exception);
|
||||
logger.warn("Unable to read tag details", exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.repo.tagging;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -2121,4 +2123,16 @@ public class TaggingServiceImplTest extends TestCase
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testTagFileRead() throws UnsupportedEncodingException
|
||||
{
|
||||
List<TagDetails> tags = TaggingServiceImpl.readTagDetails(new ByteArrayInputStream("Tag1|10\nTag2|20\nInvalid\nInvalid2|\nInvalid3|One\nTooMany|1|2\n\n".getBytes("UTF-8")));
|
||||
assertEquals(3, tags.size());
|
||||
assertEquals(tags.get(0).getName(), "Tag1");
|
||||
assertEquals(tags.get(1).getName(), "Tag2");
|
||||
assertEquals(tags.get(2).getName(), "TooMany");
|
||||
assertEquals(tags.get(0).getCount(), 10);
|
||||
assertEquals(tags.get(1).getCount(), 20);
|
||||
assertEquals(tags.get(2).getCount(), 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user