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

[#noissue] Validate SqlUidMetaDataBo #11330

Merged
merged 1 commit into from
Aug 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import com.navercorp.pinpoint.collector.dao.SqlUidMetaDataDao;
import com.navercorp.pinpoint.common.server.bo.SqlUidMetaDataBo;
import com.navercorp.pinpoint.common.util.StringUtils;
import jakarta.validation.Valid;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.Objects;

@Service
@Validated
public class HbaseSqlUidMetaDataService implements SqlUidMetaDataService {
private final SqlUidMetaDataDao sqlUidMetaDataDao;

Expand All @@ -21,7 +24,7 @@ public HbaseSqlUidMetaDataService(SqlUidMetaDataDao sqlUidMetaDataDao, Collector
}

@Override
public void insert(SqlUidMetaDataBo sqlUidMetaDataBo) {
public void insert(@Valid SqlUidMetaDataBo sqlUidMetaDataBo) {
if (sqlUidMetaDataBo.getSql().length() > maxSqlLength) {
String sql = StringUtils.abbreviate(sqlUidMetaDataBo.getSql(), maxSqlLength);
sqlUidMetaDataBo = new SqlUidMetaDataBo(sqlUidMetaDataBo.getAgentId(), sqlUidMetaDataBo.getAgentStartTime(), sqlUidMetaDataBo.getApplicationName(), sqlUidMetaDataBo.getUid(), sql);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.navercorp.pinpoint.collector.service;

import com.navercorp.pinpoint.common.server.bo.SqlUidMetaDataBo;
import jakarta.validation.Valid;

public interface SqlUidMetaDataService {
void insert(SqlUidMetaDataBo sqlUidMetaDataBo);
void insert(@Valid SqlUidMetaDataBo sqlUidMetaDataBo);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.navercorp.pinpoint.common.server.bo;

import com.navercorp.pinpoint.common.server.bo.serializer.metadata.uid.UidMetaDataRowKey;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.PositiveOrZero;

import java.util.Arrays;
import java.util.Objects;

public class SqlUidMetaDataBo implements UidMetaDataRowKey {
private final String agentId;
private final long startTime;
private final String applicationName;
@NotBlank private final String agentId;
@PositiveOrZero private final long startTime;
@NotBlank private final String applicationName;

private final byte[] sqlUid;
private final String sql;
@NotBlank private final String sql;

public SqlUidMetaDataBo(String agentId, long startTime, byte[] sqlUid, String sql) {
this.agentId = Objects.requireNonNull(agentId, "agentId");
Expand Down