Skip to content

Commit

Permalink
#28779 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Sep 4, 2024
1 parent b7fbe51 commit 4ecc05c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ This maintenance release includes the following code fixes:
140. https://github.com/dotCMS/core/issues/28857 : dotAsset is Breaking FileViewStrategy #28857
141. https://github.com/dotCMS/core/issues/29259 : Page API: Image field content gone when request page with depth #29259
142. https://github.com/dotCMS/core/issues/29667 : Update CLEANUP_BUNDLES_OLDER_THAN_DAYS default value to 4 #29667
143. https://github.com/dotCMS/core/issues/29162 : Slow performance with imports in some cases #29162
143. https://github.com/dotCMS/core/issues/29162 : Slow performance with imports in some cases #29162
144. https://github.com/dotCMS/core/issues/28779 : IndexOutOfBoundsException in sitesearch portlet #28779
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ private void setDefaultToSpecificPosition(final List<String> list, final int ind
if (defaultIndice != null && !defaultIndice.isEmpty() && !list.isEmpty() ){
final int index = list.indexOf(defaultIndice);
//change the element defaultIndex to the first position of the arraylist if it is not yet
if (index != 0) {
if(index < 0){
Logger.warn(this.getClass(), String.format("The default site search '%s' index was not found in the list of indices.", defaultIndice));
} else {
list.remove(index);
list.add(indexPosition, defaultIndice);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,36 @@ public void test_listIndices_defaultIndicesShouldFirst() throws IOException, Dot
assertTrue(indiciesAPI.loadIndicies().getSiteSearch().equals(defIndex));
assertEquals(defIndex, indices.get(0));
}

/**
* Method to test: {@link SiteSearchAPI#listIndices()}
* Given Scenario: Create a few SiteSearch, set one as default, delete it, Attempt to load the list.
* ExpectedResult: The list should load fine, a WARN message should be logged regarding Default Index not found.
*/
@Test
public void test_listIndices_defaultIndexNotExist() throws IOException, DotDataException {
String timeStamp, indexName, aliasName;
String defIndex = "";

final int indicesAmount = 3;
for (int i = 0; i < indicesAmount; i++) {
timeStamp = String.valueOf(new Date().getTime());
indexName = ES_SITE_SEARCH_NAME + "_" + timeStamp;
aliasName = "indexAlias" + "_" + timeStamp;

siteSearchAPI.createSiteSearchIndex(indexName, aliasName, 1);

if (i == 2){
//sets as default
siteSearchAPI.activateIndex(indexName);
defIndex = indexName;
}
}

//delete the default index
indexAPI.delete(defIndex);

//get the list of indices (previously was throwing an IndexOutOfBoundsException)
siteSearchAPI.listIndices();
}
}

0 comments on commit 4ecc05c

Please sign in to comment.