#fixed code
                                int lastIndexFile(int cycle) {
        return lastIndexFile(cycle, 0);
    }
#vulnerable code 
                                int lastIndexFile(int cycle, int defaultCycle) {
        int maxIndex = -1;

        final File cyclePath = new File(baseFile, dateCache.formatFor(cycle));
        final File[] files = cyclePath.listFiles();
        if (files != null) {
            for (final File file : files) {
                String name = file.getName();
                if (name.startsWith(FILE_NAME_PREFIX)) {
                    int index = Integer.parseInt(name.substring(FILE_NAME_PREFIX.length()));
                    if (maxIndex < index) {
                        maxIndex = index;
                    }
                }
            }
        }

        return maxIndex != -1 ? maxIndex : defaultCycle;
    } 
                            #location 4 
                            #vulnerability type THREAD_SAFETY_VIOLATION