Skip to content

Commit

Permalink
Fix NPE when Component not found by artifact in ExportDependenciesToT…
Browse files Browse the repository at this point in the history
…eamcityTask (#41)
  • Loading branch information
aryabokon committed Dec 27, 2023
1 parent 0e676c1 commit 0769a3c
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.octopusden.octopus.components.registry.client.impl.ClassicComponentsRegistryServiceClient;
import org.octopusden.octopus.components.registry.client.impl.ClassicComponentsRegistryServiceClientUrlProvider;
import org.octopusden.octopus.components.registry.core.dto.ArtifactDependency;
import org.octopusden.octopus.components.registry.core.dto.VersionedComponent;
import org.octopusden.release.management.plugins.gradle.ReleaseDependenciesConfiguration;
import org.octopusden.release.management.plugins.gradle.ReleaseManagementDependenciesExtension;
import org.octopusden.release.management.plugins.gradle.dto.ComponentArtifact;
Expand All @@ -21,6 +22,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -103,7 +105,18 @@ private List<String> getArtifactDependenciesString(ReleaseDependenciesConfigurat
return getComponentsRegistryServiceClient().findArtifactComponentsByArtifacts(artifacts)
.getArtifactComponents()
.stream()
.map(ac -> String.format(COMPONENT_FORMAT, ac.getComponent().getId(), ac.getComponent().getVersion()))
.map(ac -> {
final VersionedComponent component = ac.getComponent();
final String result;
if (component == null) {
getLogger().error("ExportDependenciesToTeamcityTask Component not found by {}", ac.getArtifact());
result = null;
} else {
result = String.format(COMPONENT_FORMAT, component.getId(), component.getVersion());
}
return result;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
}

Expand Down

0 comments on commit 0769a3c

Please sign in to comment.