Remove this use of "Double"; it is deprecated.
2023, May 13
problem
if (StringUtils.isNotEmpty(appUserId)) {
return String.format("%.0f", new Double(appUserId));
}
- double값을 정수형으로 변환하고 다시 문자열로 바꾼후 소수점이하를 버리는 코드가 sonarqube에 검출되었습니다.
cause
- 원인은 자바 1.9부터 기본 자료형의 박싱 클래스들은 모두 deprecated된 것으로 소나큐브의 자바버전을 17로 올린 이후에 검출된 것이였습니다.
solve
팩토리 메소드 Double.valueOf로 변경하도록 합니다. 인스턴스를 생성하는 new Double보다 성능측면으로도 좋다고 볼 수 있습니다.
return String.format("%.0f", Double.valueOf(appUserId));
Reference
https://stackoverflow.com/questions/60024551/alternative-for-deprecated-new-doubledouble