#vulnerable code 
                                public static int getLineCount(String str) {
        LineNumberReader reader = new LineNumberReader(new StringReader(str));
        try {
            reader.skip(Long.MAX_VALUE);
            return reader.getLineNumber();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // Ignore but warn
                log.warn("Can not close reader", e);
            }
        }
    } 
                            #location 10 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public static int getLineCount(String str) {
        if (null == str || str.isEmpty()) {
            return 0;
        }
        int count = 1;
        for (char c : str.toCharArray()) {
            if ('\n' == c) {
                count++;
            }
        }
        return count;
    }