Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug that used an empty list of transactions to check for nodes #61

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
}


}
}
Loading