#vulnerable code 
                                public String generate(NameGenerationRequest request) {
        if (request == null) {
            throw new IllegalArgumentException("Unable to generate a name for a null request.");
        }
        String result = toSafeFilename(
                prefixTypesChain.process(prefix, ofNullable(request).orElseGet(() -> nameRequest())));

        String osName = System.getProperty("os.name").toLowerCase();
        if (osName.contains("win") || osName.contains("mac")) {
            // char based max length
            result = shortenFilenameCharLength(result, 255);
        } else {
            // bytes based max length
            result = shortenFilenameBytesLength(result, 254, StandardCharsets.UTF_8);
        }

        return result;
    } 
                            #location 8 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public String generate(NameGenerationRequest request) {
        if (request == null) {
            throw new IllegalArgumentException("Unable to generate a name for a null request.");
        }
        return toSafeFilename(prefixTypesChain.process(prefix, ofNullable(request).orElseGet(() -> nameRequest())));
    }