Skip to content

Fix NullPointerException when using IterableSpec any()#341

Merged
seongahjo merged 7 commits into
naver:mainfrom
kshired:fix-npe
Jun 14, 2022
Merged

Fix NullPointerException when using IterableSpec any()#341
seongahjo merged 7 commits into
naver:mainfrom
kshired:fix-npe

Conversation

@kshired
Copy link
Copy Markdown
Contributor

@kshired kshired commented Jun 9, 2022

Resolve #323

IterableSpec any에서 size를 지정하지 않았을 때 ( 혹은 min , max 중 하나만 지정한 경우 ) , 발생하는 문제를 해결하였습니다.

#323 이슈에서 언급되었던 Arbitraries.longs().between(this.minSize, this.maxSize).sample(); 코드는 39179a1 에서 수정되었음을 확인했습니다.

따라서 다른 곳에서 문제점이 있음을 인지하고, 파악하였으며 파악한 문제점은 아래와 같습니다.

  1. random에 의해 limit이 0으로 설정되었을 때, ArbitrarySet 클래스의 getApplicableValue()에 의해 sample이 생성되지 않는 경우
    • 리스트에 any에서 할당한 값이 설정되지 않는 경우
  2. max가 설정되지 않고, min은 설정되었지만 min이 DEFAULT_ELEMENT_MAX_SIZE보다 큰 경우
    • boundary 관련 exception이 발생하는 경우
  3. max, min이 둘 다 설정되지 않았을 때, DEFAULT_ELEMENT_MIN_SIZE 에 의해 size가 0인 list가 반환되는 경우
    • 반환된 리스트가 빈 리스트인 경우

위 3가지 문제를 해결하고, 테스트 코드를 추가하였습니다.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 9, 2022

CLA assistant check
All committers have signed the CLA.

@seongahjo seongahjo added this to the 0.3.4 milestone Jun 10, 2022
@kshired kshired requested a review from seongahjo June 10, 2022 11:53
@seongahjo seongahjo merged commit 557c3c4 into naver:main Jun 14, 2022
@mhyeon-lee mhyeon-lee removed this from the 0.3.4 milestone Jun 21, 2022
@seongahjo
Copy link
Copy Markdown
Contributor

seongahjo commented Jun 21, 2022

@kshired 님 올려주신 PR 반영하여 0.3.5 배포하였습니다~ 감사합니다.

https://github.com/naver/fixture-monkey/releases/tag/0.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullPointerException when using IterableSpec any()

4 participants