Skip to content

Commit

Permalink
Fix: VpcFetch 내 nullpointException 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
gytjd committed Nov 18, 2024
1 parent cea2041 commit 622ab65
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private MemberCredentialDTO getMemberCredentials(String email, String companyNam
);

System.out.println(response.getBody().getData());

// 응답 상태와 데이터 유효성 확인
if (response.getStatusCode().is2xxSuccessful() &&
response.getBody() != null &&
Expand Down Expand Up @@ -149,15 +149,14 @@ public List<RouteTableResponseDto> fetchRouteTables(String userId,String company
}

// VPCs 가져오기
public List<VpcTotalResponseDto> fetchVpcs(String userId,String companyName) {

initializeClient(userId,companyName);
public List<VpcTotalResponseDto> fetchVpcs(String userId, String companyName) {
initializeClient(userId, companyName);

DescribeVpcsRequest request = DescribeVpcsRequest.builder().build();
DescribeVpcsResponse response = ec2Client.describeVpcs(request);

List<SubnetResponseDto> subnets = fetchSubnets(userId,companyName);
List<RouteTableResponseDto> routeTables = fetchRouteTables(userId,companyName);
List<SubnetResponseDto> subnets = fetchSubnets(userId, companyName);
List<RouteTableResponseDto> routeTables = fetchRouteTables(userId, companyName);

return response.vpcs().stream()
.map(vpc -> {
Expand All @@ -168,15 +167,17 @@ public List<VpcTotalResponseDto> fetchVpcs(String userId,String companyName) {
.filter(subnet -> subnet.getVpcId().equals(vpc.vpcId()))
.collect(Collectors.toList());

// Null 체크를 추가하여 VpcId가 null인 경우 예외가 발생하지 않도록 처리
List<RouteTableResponseDto> associatedRouteTables = routeTables.stream()
.filter(routeTable -> routeTable.getVpcId().equals(vpc.vpcId()))
.filter(routeTable -> routeTable.getVpcId() != null && routeTable.getVpcId().equals(vpc.vpcId()))
.collect(Collectors.toList());

return new VpcTotalResponseDto(vpc.vpcId(), vpc.cidrBlock(), tagsMap, associatedSubnets, associatedRouteTables);
})
.collect(Collectors.toList());
}


// Security Groups 가져오기
public List<SecurityGroupDTO> fetchSecurityGroups(String userId,String companyName) {

Expand Down

0 comments on commit 622ab65

Please sign in to comment.