An 'int' is expected rather than a Object.

2022, Jun 21    

cause

**Printf-style format strings should not lead to unexpected behavior at runtime**

Because printf -style format strings are interpreted at runtime, rather than validated by the Java compiler, they can contain errors that lead to unexpected behavior or runtime errors. This rule statically validates the good behavior of printf -style formats when calling the format(...)  methods of java.util.Formatterjava.lang.Stringjava.io.PrintStreamMessageFormat , and java.io.PrintWriter  classes and the printf(...)  methods of java.io.PrintStream  or java.io.PrintWriter  classes.

code

private String parsingAppUserId(Object appUserId) {
        try {
            return String.format("%d", appUserId);
        } catch(Exception e) {
            return StringUtils.EMPTY;
        }
        return StringUtils.EMPTY;
    }

int로 변환하는 포맷인데 Object타입으로 받아서 발생한 것

solution

int로 변환함

private String parsingAppUserId(Object appUserId) {
        try {
            return String.format("%d", Integer.valueOf((String) appUserId));
        } catch(Exception e) {
            return StringUtils.EMPTY;
        }
        return StringUtils.EMPTY;
    }