Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
remove copyProperties for performance boost
Browse files Browse the repository at this point in the history
  • Loading branch information
rvema committed Mar 28, 2022
1 parent 2c90dbd commit 55eb1e6
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public DataResponse<Iterable<Build>> search(BuildSearchRequest request) {

return new DataResponse<>(result, collector.getLastExecuted());
}

protected Build createBuild(BuildDataCreateRequest request) throws HygieiaException {
/**
* Step 1: create Collector if not there
Expand Down Expand Up @@ -174,16 +173,11 @@ public BuildDataCreateResponse createV3(BuildDataCreateRequest request) throws H
BuildDataCreateResponse response = new BuildDataCreateResponse();
Build build = createBuild(request);
String clientReference = StringUtils.isNotEmpty(build.getClientReference()) ? build.getClientReference() : request.getClientReference();
if(build == null) throw new HygieiaException("Unable to create build for request.", HygieiaException.ERROR_INSERTING_DATA);
populateBuildDateResponse(response, build);
if(settings.isLookupDashboardForBuildDataCreate()) {
try {
org.apache.commons.beanutils.BeanUtils.copyProperties(response, build);
populateDashboardId(response);
} catch (IllegalAccessException | InvocationTargetException e) {
LOGGER.error(String.format("correlation_id=%s, build_url=%s, build_duration_millis=%d, build_started_by=%s, build_status=%s, hygieia_build_id=%s, hygieia_build_view_link=%s, hygieia_build_error=%s"
, clientReference, build.getBuildUrl(), build.getDuration(), build.getStartedBy(), build.getBuildStatus(), build.getId(), settings.getHygieia_ui_url()+"/build/"+build.getId(), e.getMessage()));
}
populateDashboardId(response);
}

response.setClientReference(clientReference);
// Will be refactored soon
CollectorItem buildCollectorItem = collectorItemRepository.findOne(build.getCollectorItemId());
Expand Down Expand Up @@ -222,6 +216,19 @@ public BuildDataCreateResponse createV3(BuildDataCreateRequest request) throws H
return response;
}

private void populateBuildDateResponse(BuildDataCreateResponse response, Build build) {
if (response == null || build == null) return;
response.setCollectorItemId(build.getCollectorItemId());
response.setTimestamp(build.getTimestamp());
response.setNumber(build.getNumber());
response.setBuildUrl(build.getBuildUrl());
response.setStartTime(build.getStartTime());
response.setEndTime(build.getEndTime());
response.setDuration(build.getDuration());
response.setBuildStatus(build.getBuildStatus());
response.setStartedBy(build.getStartedBy());
}

private String buildStageErrorLog (BuildStage buildStage) {
if(Objects.isNull(buildStage) || Objects.isNull(buildStage.getError())) return "";
return " build_stage_error="+buildStage.getError().getType()+":"+buildStage.getError().getMessage();
Expand Down

0 comments on commit 55eb1e6

Please sign in to comment.