mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
[MNT-23094] Prevent ArrayIndexOutOfBoundsException when sorting by empty field
This commit is contained in:
+8
-1
@@ -179,7 +179,14 @@ public class AlfrescoCollatableTextFieldType extends StrField
|
||||
else if (withLocale.startsWith("\u0000"))
|
||||
{
|
||||
String[] parts = withLocale.split("\u0000");
|
||||
return parts[2];
|
||||
if (parts != null && parts.length == 3)
|
||||
{
|
||||
return parts[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
return withLocale;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+13
@@ -173,4 +173,17 @@ public class AlfrescoCollatableTextFieldTypeTest
|
||||
verify(mockCollator).compare("NotNull1", "NotNull2");
|
||||
assertEquals("Expected result to be obtained from collator.", comparisonResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMNT23094()
|
||||
{
|
||||
// Set up the document to have an encoded value for the field.
|
||||
when(mockDocTerms.get(DOC)).thenReturn(new BytesRef("\u0000"));
|
||||
when(mockDocsWithField.get(DOC)).thenReturn(false);
|
||||
|
||||
// Call the method under test.
|
||||
textSortFieldComparator.compareBottom(DOC);
|
||||
|
||||
verify(mockCollator).compare(BOTTOM_STRING, "\u0000");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user