본문 바로가기
728x90
반응형

java21

[Java 21] Virtual Thread 요약 Java 8 이후 세 번째 LTS버전인 Java 21이 2023년 9월에 릴리즈 예정인데, 이 버전에 Virtual Thread 기능이 추가될 예정입니다. (현재 Java 19에 Preview Features로 들어가 있음) 그래서 Virtual Thread 주제로 포스팅하려고 보니 이미 잘 정리되어 있는 포스팅이 많아서 요약정리만 하겠습니다. 높은 처리량을 보장하는 Reactive Programming인 Spring Webflux는 Mono나 FLux와 같은 Publisher 타입으로 값을 래핑 해야 하기 때문에 코드 가독성이 좋지 않고, 고성능을 보장하더라도 유지보수가 어렵고 러닝커브가 존재합니다. 최신 pinpoint 버전에서는 webflux도 지원하지만 이전 버전에서는 pinpoint로 안 잡힘 .. 2023. 5. 15.
[Java] Exception이 성능에 미치는 영향 예전에 Exception에 대해 포스팅했었는데, 이번엔 Exception이 성능에 미치는 영향에 대해 알아보겠습니다. [java] 예외처리 Exception handling 이 글은 Java의 정석 (남궁성/도우출판) 기반으로 작성되었습니다. 1. 프로그램 오류 컴파일 에러(compile-time error): 컴파일할 때 발생하는 에러 런타임 에러(runtime error): 실행할 때 발생하는 에러 에 moonsiri.tistory.com 예외 처리 장점 프로그램 실행 완료를 위한 제공 프로그램 코드 및 오류 처리 코드를 쉽게 식별 오류 전파 의미 있는 오류 보고 오류 유형 식별 JVM 예외 처리 순서 예외가 발생하게 되면, JVM은 발생한 예외를 처리할 수 있는 exception handler(tr.. 2023. 3. 19.
[java] Customizing redisCodec for redisCommands redis command를 날렸을 때 Key는 String, Value는 Object class로 받고 싶어서 커스텀 한 redisCodec입니다. key는 io.lettuce.core.codec.StringCodec, value는 io.lettuce.core.codec.ByteArrayCodec 참조하여 구현 import io.lettuce.core.codec.RedisCodec; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.util.CharsetUtil; import org.springframework.util.SerializationUtils; import java.nio.ByteBuffer; imp.. 2023. 2. 9.
[JAVA] UUID 중복 확률 UUID를 단순히 유니크 값이라고 생각해왔는데 얼마나 유니크하고 정말 중복될 확률이 없는지 알아보겠습니다. UUID란? UUID(universally unique identifier)란, 범용 고유 식별자로 네트워크 상에서 서로 모르는 개체들을 식별하고 구별하기 위해 개발주체가 스스로 이름을 짓도록 하되 고유성을 충족할 수 있는 방법입니다. 총 36개 문자(32개 문자와 4개의 하이픈, 128bit)로 된 8-4-4-4-12라는 5개의 그룹을 하이픈으로 구분합니다. 예) 550e8400-e29b-41d4-a716-446655440000 중간에 4는 버전을 나타냅니다. 버전 v1 : timestamp + MAC 주소 v2 : timestamp + MAC 주소 + DCE 보안 v3 : name-based +.. 2022. 8. 9.
[Java] Handler dispatch failed; nested exception is java.lang.NoSuchFieldError: public class NoSuchFieldError extends IncompatibleClassChangeError Thrown if an application tries to access or modify a specified field of an object, and that object no longer has that field. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. Since: JDK1.0 NoSuchFieldError는 보통 해당 객체에 해당 필드가 더 이상 없는 경우 throw.. 2022. 7. 21.
[Java] java.time.format.DateTimeParseException: Text 'yyyyMMdd' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to yyyy-MM-dd of type java.time.format.Parsed LocalDateTime.parse("20220720", DateTimeFormatter.ofPattern("yyyyMMdd")); java.time.format.DateTimeParseException: Text '20220720' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2022-07-20 of type java.time.format.Parsed 위 코드를 실행 시 DateTimeParseException 이 발생하는 이유는 자바가 Base Date 값을 DateTime으로 허용하지 않기때문입니다. LocalDateTime 대신 LocalDate를 사용하면 문제가 해결됩니다... 2022. 7. 20.
[Java] 사용 가능한 모든 Locale, Country 조회 java.util.Locale 를 사용합니다. 사용 가능한 모든 Locale 객체 조회 Locale[] availableLocales = Locale.getAvailableLocales(); 모든 Locale 객체의 Country 조회 String[] countries = Locale.getISOCountries(); [Reference] https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html 2022. 6. 3.
[JAVA] null 대신 Optional 그동안 NullPointerException을 피하기 위해 어떻게 해결해 왔을까? 다음은 null 확인 코드를 추가해서 NullPointerException을 줄이려는 코드입니다. // null 안전시도 1: 깊은 의심 public String getCarInsuranceName(Person person) { if (person != null) { // null 확인 Car car = person.getCar(); if (car != null) { // null 확인 Insurance insurance = car.getInsurance(); if (insurance != null) { // null 확인 return insurance.getName(); } } } return "Unknown"; } 더보.. 2022. 4. 24.
[JAVA] 파일 암호화 (Encrypt file using java) 1. 이미지 파일 암호화/복호화 public class ImgCryptUtils { private int KEY = 123; // key is act as password to Encrypt and Decrypt the Image private String FILE_PATH = "C:\\Users\\moonsiri\\Downloads\\photo.jpg"; public void encrypt() throws IOException { // Selecting a Image for operation FileInputStream fis = new FileInputStream(FILE_PATH); // Converting Image into byte array, create a array of same size .. 2021. 11. 1.
[Java] LocalDateTime format to string, LocalDateTime parse string 1. LocalDateTime format to string String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) 2. LocalDateTime parse string LocalDateTime dateTime = LocalDateTime.parse("2021-06-11 13:37:33", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) 2021. 6. 11.
728x90
반응형