#vulnerable code 
                                public static Charset getSupportedCharset(final String charsetName) {
        Charset charset = null;
        if (charsetName != null) {
            if (Charset.isSupported(charsetName)) {
                charset = Charset.forName(charsetName);
            }
        }
        if (charset == null) {
            charset = Charset.forName(UTF_8);
            if (charsetName != null) {
                StatusLogger.getLogger().error("Charset " + charsetName + " is not supported for layout, using " +
                    charset.displayName());
            }
        }
        return charset;
    } 
                            #location 12 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public static Charset getSupportedCharset(final String charsetName) {
        Charset charset = null;
        if (charsetName != null) {
            if (Charset.isSupported(charsetName)) {
                charset = Charset.forName(charsetName);
            }
        }
        if (charset == null) {
            charset = UTF_8;
            if (charsetName != null) {
                StatusLogger.getLogger().error("Charset " + charsetName + " is not supported for layout, using " +
                    charset.displayName());
            }
        }
        return charset;
    }