2023-01-10-TIL

Today I Learned

Get Empty String When Null

Objects.toString(id, "");
Optional.ofNullable(id).orElse("");
StringUtils.defaultString(str).replaceAll("^(?i)null$", "");

Java 8 이상에서는 Optional을 사용해서 null 처리를 하는게 깔끔한 것 같다.

  • https://stackoverflow.com/questions/21936503/get-empty-string-when-null

Servlet, HttpServletRequest

  • https://tragramming.tistory.com/99
  • https://velog.io/@oliviarla/HttpServletRequest-HttpServletResponse-%EA%B0%9D%EC%B2%B4%EB%9E%80
  • https://kgvovc.tistory.com/41#:~:text=HttpServletRequest%20%EA%B0%9D%EC%B2%B4%EB%A5%BC%20%ED%86%B5%ED%95%9C%20%EC%A0%95%EB%B3%B4,%EC%9A%94%EC%B2%AD%20%EC%9E%AC%EC%A7%80%EC%A0%95'%EC%9D%B4%EB%9D%BC%EA%B3%A0%20%ED%95%A9%EB%8B%88%EB%8B%A4.

Logback

  • https://logback.qos.ch/manual/introduction.html
  • https://www.baeldung.com/logback
  • https://ckddn9496.tistory.com/86
  • https://kimpaper.github.io/2015/10/30/logback-config/

Get Client IP From HttpServletRequest

String ipAddress = request.getHeader("X-FORWARDED-FOR");  
if (ipAddress == null) {  
    ipAddress = request.getRemoteAddr();  
}

HttpServletRequest로부터 클라이언트 IP를 위와 같이 얻어올 수 있는데, FE를 통해서 들어온 IP는 FE의 IP가 찍힐 수 있다. 따라서 실제 사용자의 IP를 가져오려면 클라이언트인 FE서버가 X-FORWARDED-FOR 헤더에 실제 사용자의 IP를 실어서 보내주어야 한다.

  • http://jmlim.github.io/java/2018/12/14/java-client-ip/
  • https://stackoverflow.com/questions/29910074/how-to-get-client-ip-address-in-java-httpservletrequest

Rolling Logs Every 15 Minutes With Logback

  • https://ronanquillevere.github.io/2015/08/04/rolling-log-15-min.html#.Y7uniuxBzgF
  • https://reference-m1.tistory.com/349

Spring Logging

  • https://www.baeldung.com/spring-http-logging

Spring Boot AOP Logging Request Body

  • https://www.javaguides.net/2019/05/spring-boot-spring-aop-logging-example-tutorial.html
  • https://threepotatoteers.medium.com/use-spring-aop-to-log-post-requests-6abee5753464
  • https://www.springcloud.io/post/2022-03/record-request-and-response-bodies/#gsc.tab=0
  • https://meetup.nhncloud.com/posts/44
  • https://dylee.tistory.com/6
  • https://twofootdog.github.io/Spring-POST%EB%B0%A9%EC%8B%9D%EC%9C%BC%EB%A1%9C-%EC%A0%84%EB%8B%AC%EB%90%9C-JSON-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%B2%98%EB%A6%AC%ED%95%98%EA%B8%B0/
  • https://hirlawldo.tistory.com/42
  • https://taetaetae.github.io/2019/06/30/controller-common-logging/
  • https://stackoverflow.com/questions/63008446/get-requestbody-using-aspectj

Spring AOP

  • https://www.digitalocean.com/community/tutorials/spring-aop-example-tutorial-aspect-advice-pointcut-joinpoint-annotations
  • https://www.linkedin.com/pulse/logging-spring-requests-using-aspect-abd-alrhman-alkraien?trk=pulse-article_more-articles_related-content-card
  • https://pamyferret.tistory.com/51

Get Request Body With Spring Interceptor

  • https://xzio.tistory.com/1999

Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider

M1에서 해당 에러가 발생하면 스프링 의존을 추가해주면 된다.

  • https://github.com/netty/netty/issues/11020

Spotify Architecture

  • https://www.techaheadcorp.com/blog/decoding-software-architecture-of-spotify-how-microservices-empowers-spotify/
  • https://medium.com/geekculture/spotify-system-architecture-6bb418db6084
  • https://engineering.atspotify.com/2016/08/commodity-music-ml-services/
  • https://engineering.atspotify.com/2013/03/backend-infrastructure-at-spotify/
  • https://www.infoq.com/news/2022/07/spotify-system-model-c4/
  • https://www.linkedin.com/pulse/spotify-system-architecture-omar-ismail?trk=pulse-article

ERD Tools

  • https://gitmind.com/kr/er-diagram-tool.html
  • https://online.visual-paradigm.com/diagrams/features/erd-tool/
  • https://trevor.io/blog/top-7-entity-relationship-diagram-tools
  • https://www.comparitech.com/net-admin/er-diagram-tools/
  • https://www.guru99.com/free-database-diagram-design-tools.html
  • https://www.holistics.io/blog/top-5-free-database-diagram-design-tools/
  • http://www.uniondata.co.kr/product/da-shop/