Skip to content
1 change: 1 addition & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
between `opentelemetry-exporter-zipkin-proto-http` (protobuf~=3.12) and `opentelemetry-proto` (protobuf>=5.0).
* Fix missing `taskId` filter and incorrect `IN` clause parameter binding in `JDBCJFRDataQueryDAO` and `JDBCPprofDataQueryDAO`.
* Remove deprecated `GroupBy.field_name` from BanyanDB `MeasureQuery` request building (Phase 1 of staged removal across repos).
* Push `taskId` filter down to the storage layer in `IAsyncProfilerTaskLogQueryDAO`, removing in-memory filtering from `AsyncProfilerQueryService`.

#### UI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,7 @@ public AsyncProfilerStackTree queryJFRData(String taskId, List<String> instanceI
}

public List<AsyncProfilerTaskLog> queryAsyncProfilerTaskLogs(String taskId) throws IOException {
List<AsyncProfilerTaskLog> taskLogList = getTaskLogQueryDAO().getTaskLogList();
return findMatchedLogs(taskId, taskLogList);
}

private List<AsyncProfilerTaskLog> findMatchedLogs(final String taskID, final List<AsyncProfilerTaskLog> allLogs) {
return allLogs.stream()
.filter(l -> Objects.equals(l.getId(), taskID))
return getTaskLogQueryDAO().getTaskLogList(taskId).stream()
.map(this::extendTaskLog)
.collect(Collectors.toList());
Comment on lines 104 to 107
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTaskLogList(taskId) is now called directly and the ES implementation uses Query.term(..., taskId) which throws a NullPointerException when taskId is null. To keep behavior consistent across storage implementations (JDBC would just bind null) and avoid unexpected NPEs, add a fast-fail/guard here (e.g., validate taskId is non-null/non-blank and return empty list or throw an IllegalArgumentException with a clear message) before invoking the DAO.

Copilot uses AI. Check for mistakes.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

public interface IAsyncProfilerTaskLogQueryDAO extends DAO {
/**
* search all task log list in appoint task id
* Search task logs by the given task id.
*
* @param taskId the task id to filter by, must not be null or blank
* @return the task logs associated with the given task id
* @throws IOException if the query fails
*/
List<AsyncProfilerTaskLog> getTaskLogList() throws IOException;
List<AsyncProfilerTaskLog> getTaskLogList(String taskId) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ public BanyanDBAsyncProfilerTaskLogQueryDAO(BanyanDBStorageClient client, int ta
}

@Override
public List<AsyncProfilerTaskLog> getTaskLogList() throws IOException {
public List<AsyncProfilerTaskLog> getTaskLogList(String taskId) throws IOException {
StreamQueryResponse resp = query(false, AsyncProfilerTaskLogRecord.INDEX_NAME, TAGS,
new QueryBuilder<StreamQuery>() {
@Override
public void apply(StreamQuery query) {
query.and(eq(AsyncProfilerTaskLogRecord.TASK_ID, taskId));
query.setLimit(BanyanDBAsyncProfilerTaskLogQueryDAO.this.queryMaxSize);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ public AsyncProfilerTaskLogQueryEsDAO(ElasticSearchClient client, int queryMaxSi
}

@Override
public List<AsyncProfilerTaskLog> getTaskLogList() throws IOException {
public List<AsyncProfilerTaskLog> getTaskLogList(String taskId) throws IOException {
final String index = IndexController.LogicIndicesRegister.getPhysicalTableName(
AsyncProfilerTaskLogRecord.INDEX_NAME);
final BoolQueryBuilder query = Query.bool();
if (IndexController.LogicIndicesRegister.isMergedTable(AsyncProfilerTaskLogRecord.INDEX_NAME)) {
query.must(Query.term(IndexController.LogicIndicesRegister.RECORD_TABLE_NAME, AsyncProfilerTaskLogRecord.INDEX_NAME));
}
query.must(Query.term(AsyncProfilerTaskLogRecord.TASK_ID, taskId));
final SearchBuilder search =
Comment on lines 49 to 58
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query.term(..., taskId) will throw a NullPointerException with a generic message ("value") if taskId is null. Consider validating taskId at the start of this method (e.g., requireNonNull / checkArgument) and throwing an IllegalArgumentException with a clearer message, so failures are easier to diagnose and consistent with other storage implementations.

Copilot uses AI. Check for mistakes.
Search.builder().query(query)
.sort(AsyncProfilerTaskLogRecord.OPERATION_TIME, Sort.Order.DESC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public class JDBCAsyncProfilerTaskLogQueryDAO implements IAsyncProfilerTaskLogQu

@Override
@SneakyThrows
public List<AsyncProfilerTaskLog> getTaskLogList() {
public List<AsyncProfilerTaskLog> getTaskLogList(String taskId) {
List<String> tables = tableHelper.getTablesWithinTTL(AsyncProfilerTaskLogRecord.INDEX_NAME);
final List<AsyncProfilerTaskLog> results = new ArrayList<AsyncProfilerTaskLog>();
for (String table : tables) {
SQLAndParameters sqlAndParameters = buildSQL(table);
SQLAndParameters sqlAndParameters = buildSQL(table, taskId);
List<AsyncProfilerTaskLog> logs = jdbcClient.executeQuery(
sqlAndParameters.sql(),
resultSet -> {
Expand All @@ -62,12 +62,14 @@ public List<AsyncProfilerTaskLog> getTaskLogList() {
return results;
}

private SQLAndParameters buildSQL(String table) {
private SQLAndParameters buildSQL(String table, String taskId) {
StringBuilder sql = new StringBuilder();
List<Object> parameters = new ArrayList<>(2);
sql.append("select * from ").append(table)
.append(" where ").append(JDBCTableInstaller.TABLE_COLUMN).append(" = ?");
parameters.add(AsyncProfilerTaskLogRecord.INDEX_NAME);
sql.append(" and ").append(AsyncProfilerTaskLogRecord.TASK_ID).append(" = ?");
parameters.add(taskId);
sql.append(" order by ").append(AsyncProfilerTaskLogRecord.OPERATION_TIME).append(" desc");
return new SQLAndParameters(sql.toString(), parameters);
}
Expand Down
Loading