본문 바로가기

개발이야기

MockMvc Test 대신 실제 Url 호출 테스트 (서블릿 필터 테스트) 서블릿 필터를 테스트 하고 싶었는데 ... mockMvc 테스트로는 제대로 호출을 할수가 안됨. @SpringBootTest를 이용해 랜덤포트로 띄우고 restTemplate 으로 호출하면 되더라. 간단한건데 바로 생각이 안나서 좀 삽질했음. @ActiveProfiles("sandbox") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class FilterTest @Autowired constructor( val restTemplate: TestRestTemplate ) { val internalUrl = "/api/v1/internal/use" @Test @DisplayName("appGw 통해서 internal.. 더보기
JPA 업데이트 동시성 문제 (feat. @DynamicUpdate) JPA 업데이트 동시성 문제 (feat. @DynamicUpdate) 최근에 담당하는 서비스에서 이상한 케이스가 발생해서 조금 자세히 확인을 해봤습니다. 비지니스 플로우는 아래와 같습니다. 1. Insert into table_A ... 2. update table_A set terms_agreed_at = now() 3. update table_A set token_bound_at = now() 1~3 번 까지 순차적으로 발생 해야 하는데 실제 DB에 쌓인 데이터는 1번(인서트)와 3번(업데이트)만 처리되고 2번이 누락되어 terms_agreed_at 칼럼이 null 로 남아 있는 경우가 종종 발생했네요. 서버 로그를 확인해보면 .. 2번 API 호출이 정상적으로 실행 되었음에도 실제 데이터는 누락 되.. 더보기
When should you use 'private static final' 'private static final variable' vs 'private final variable' When should you use the 'static' keyword? What is the difference between 'private static final variable' and 'private final variable'? The static keyword is used when all instances of the class must have the same value. It is better to use it separately from instance variables. 더보기
DateTimeFomatter 에서 밀리세컨드 노출 여부 DateTime 이나 OffSetDateTime을 출력할때 별도의 포맷터를 지정하지 않거나 ISO DateTime 포맷터 같은걸 사용 하면 밀리세컨드가 표시될때도 있고 누락될때도 있음. 000ms 인경우 표시 없이 초 까지만 표기함 무조건 밀리세컨드 까지 표기 하려면 반드시 포맷터에 밀리세컨드 (SSS) 표기를 명시해줘야 함. 더보기
Spring session 쿠키 설정 https://docs.spring.io/spring-session/docs/current-SNAPSHOT/reference/html5/guides/java-custom-cookie.html Spring Session - Custom Cookie Once you have set up Spring Session, you can customize how the session cookie is written by exposing a CookieSerializer as a Spring bean. Spring Session comes with DefaultCookieSerializer. Exposing the DefaultCookieSerializer as a Spring bean augments the docs.. 더보기
"Apropos" terminal pops up when typing cmd+shift+A to get actions bar "Apropos" terminal pops up when typing cmd+shift+A to get actions bar https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003430700--Apropos-terminal-pops-up-when-typing-cmd-shift-A-to-get-actions-bar "Apropos" terminal pops up when typing cmd+shift+A to get actions bar Everytime I type cmd+shift+A to pop up the Actions menu to search for an action a yellow terminal window pops up.. 더보기
libqdbm.4.dylib (맥북 터미널 실행 안될때 ) 맥북 터미널 실행 안될때 ... Brew Terminal doesn’t start because “libqdbm.4.dylib" loading fails. To fix that problem, my solution follows here: Rename /usr/local/opt/gdbm/lib/libgdmb.6.dylib into usr/local/opt/gdbm/lib/libgdmb.4.dylib Attention: brew install gdmb io. but do not run brew reinstall gdmb! If not, libgdmb.4.dylib will be replaced by libgdmb.6.dylib again and forces the same failure at start t.. 더보기
PGP sign and encrypt What is PGP ? 'Pretty Good Privacy'의 약자로서, 컴퓨터 파일을 암호화하고 복호화하는 프로그램이다. 1991년 필립 짐머만이 개발하였으며, 현재 전 세계적으로 이메일 보안의 표준으로 자리잡았다. 나무위키의 PGP 역사가 재미납니다. ( https://namu.wiki/w/PGP ) 여담으로 1997년 PGP 국제버전인 PGPi 5.0이 개발되었고, 필 지머먼은 이를 국외로 수출하려고 했으나 당시 미국 정부는 암호화 프로그램을 무기로 간주하여 이를 저지한다. 이에 지머먼은 법률을 검토하던 중, 소프트웨어는 수출 금지 항목에 포함되어 있어도, 종이에 인쇄된 책은 수출에 제약이 없다는 점을 발견했다. 법의 허점이라기 보다는, 미국에서는 강력한 수정헌법 1조 덕에 출판의 자유가 보장되.. 더보기