Skip to content

Commit

Permalink
Fix bug that used an empty list of transactions to check for nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
todorinskiz committed Dec 19, 2024
1 parent 0b2ebf5 commit 70be3c3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Changelog - Alfred Health Processor
date: 31 May 2021
date: 19 December 2024
report: true
colorlinks: true
---
Expand All @@ -22,7 +22,12 @@ Version template:

# Alfresco Health Processor Changelog

## [0.5.6] - UNRELEASED
## [0.5.6] - 2024-12-19

### Fixed

*[[#60](https://github.com/xenit-eu/alfresco-health-processor/pull/60)] Fix exception when searching for an empty list of transactions for nodes in Solr


## [0.5.5] - 2024-12-16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Set;
import lombok.AllArgsConstructor;
import org.alfresco.repo.search.SearchTrackingComponent;
import org.alfresco.repo.solr.NodeParameters;

@AllArgsConstructor
public class Alfresco7TrackingComponent implements TrackingComponent {
Expand All @@ -18,9 +19,12 @@ public long getMaxTxnId() {

@Override
public Set<NodeInfo> getNodesForTxnIds(List<Long> txnIds) {
if(txnIds.isEmpty()) {
return new HashSet<>();
}
Set<NodeInfo> ret = new HashSet<>();

trackingComponent.getNodes(toNodeParameters(txnIds), node -> {
NodeParameters parameters = toNodeParameters(txnIds);
trackingComponent.getNodes(parameters, node -> {
// TODO filter out deleted nodes?
ret.add(new NodeInfo(node.getTransaction().getId(), node.getId(), node.getNodeRef()));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import eu.xenit.alfresco.healthprocessor.indexing.TrackingComponent.NodeInfo;
Expand Down Expand Up @@ -61,6 +63,11 @@ void getNodesForTxnIds() {
new NodeInfo(1L, 102L, new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "xyz-987"))));
}

@Test
void getNodesForEmptyTxnIdList() {
trackingComponent.getNodesForTxnIds(Collections.emptyList());
verify(searchTrackingComponent, never()).getNodes(any(), any());
}

private Node nodeEntity(long txnId, long nodeId, String uuid) {
Node ret = mock(Node.class);
Expand All @@ -73,4 +80,4 @@ private Node nodeEntity(long txnId, long nodeId, String uuid) {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.alfresco.repo.solr.NodeParameters;
import org.alfresco.repo.solr.SOLRTrackingComponent;

@RequiredArgsConstructor
Expand All @@ -18,9 +19,12 @@ public long getMaxTxnId() {

@Override
public Set<NodeInfo> getNodesForTxnIds(List<Long> txnIds) {
if(txnIds.isEmpty()) {
return new HashSet<>();
}
Set<NodeInfo> ret = new HashSet<>();

trackingComponent.getNodes(toNodeParameters(txnIds), node -> {
NodeParameters parameters = toNodeParameters(txnIds);
trackingComponent.getNodes(parameters, node -> {
// TODO filter out deleted nodes?
ret.add(new NodeInfo(node.getTransaction().getId(), node.getId(), node.getNodeRef()));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import eu.xenit.alfresco.healthprocessor.indexing.TrackingComponent.NodeInfo;
Expand Down Expand Up @@ -60,6 +62,11 @@ void getNodesForTxnIds() {
new NodeInfo(1L, 102L, new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "xyz-987"))));
}

@Test
void getNodesForEmptyTxnIdList() {
trackingComponent.getNodesForTxnIds(Collections.emptyList());
verify(solrTrackingComponent, never()).getNodes(any(), any());
}

private Node nodeEntity(long txnId, long nodeId, String uuid) {
Node ret = mock(Node.class);
Expand All @@ -72,4 +79,4 @@ private Node nodeEntity(long txnId, long nodeId, String uuid) {
}


}
}

0 comments on commit 70be3c3

Please sign in to comment.