Repository: Stirling-Tools/Stirling-PDF
File: src/main/java/stirling/software/SPDF/config/AppConfig.java (Java)

Code before:
                ? applicationProperties.getSystem().getEnableAlphaFunctionality()
                : false;
    }

    @Bean(name = "rateLimit")
    public boolean rateLimit() {
        String rateLimit = System.getProperty("rateLimit");
        if (rateLimit == null) rateLimit = System.getenv("rateLimit");
        return (rateLimit != null) ? Boolean.valueOf(rateLimit) : false;
    }

    @Bean(name = "uploadLimit")
    public long uploadLimit() {
        boolean uploadLimit =
                applicationProperties.getSystem().getUploadLimit().getEnableUploadSizeLimit()
                                != null
                        ? applicationProperties
                                .getSystem()
                                .getUploadLimit()
                                .getEnableUploadSizeLimit()
                        : false;
        if (!uploadLimit) {
            return 0;
        }
        String maxUploadSize = applicationProperties.getSystem().getUploadLimit().getLimit();
        if (!new Regex("^[1-9][0-9]{0,2}[K|M|G]B$").matches(maxUploadSize)) {
            log.error(
                    "Invalid maxUploadSize format. Expected format: {1,3}[0-9][K|M|G]B, but got: {}",
                    maxUploadSize);
            return 0;
        }
        if (maxUploadSize == null || maxUploadSize.isEmpty()) {
            return 0;
        } else {
            String unit = maxUploadSize.replaceAll("[1-9][0-9]{0,2}", "");
            String number = maxUploadSize.replaceAll("[K|M|G]B", "");
            long size = Long.parseLong(number);
            return switch (unit) {
                case "KB" -> size * 1024;
                case "MB" -> size * 1024 * 1024;
                case "GB" -> size * 1024 * 1024 * 1024;
                default -> 0;
            };
        }
    }

    @Bean(name = "RunningInDocker")
    public boolean runningInDocker() {
        return Files.exists(Paths.get("/.dockerenv"));
    }


Review comment (suggestion):
Would be nice to accept lower case too: `^[1-9][0-9]{0,2}[KMGkmg][Bb]$`
You can use `.toUpperCase()` on the retrieved string afterwards.

Code after:
                ? applicationProperties.getSystem().getEnableAlphaFunctionality()
                : false;
    }

    @Bean(name = "rateLimit")
    public boolean rateLimit() {
        String rateLimit = System.getProperty("rateLimit");
        if (rateLimit == null) rateLimit = System.getenv("rateLimit");
        return (rateLimit != null) ? Boolean.valueOf(rateLimit) : false;
    }

    @Bean(name = "uploadLimit")
    public long uploadLimit() {
        String maxUploadSize =
                applicationProperties.getSystem().getFileUploadLimit() != null
                        ? applicationProperties.getSystem().getFileUploadLimit()
                        : "";

        if (maxUploadSize.isEmpty()) {
            return 0;
        } else if (!new Regex("^[1-9][0-9]{0,2}[KMGkmg][Bb]$").matches(maxUploadSize)) {
            log.error(
                    "Invalid maxUploadSize format. Expected format: [1-9][0-9]{0,2}[KMGkmg][Bb], but got: {}",
                    maxUploadSize);
            return 0;
        } else {
            String unit = maxUploadSize.replaceAll("[1-9][0-9]{0,2}", "").toUpperCase();
            String number = maxUploadSize.replaceAll("[KMGkmg][Bb]", "");
            long size = Long.parseLong(number);
            return switch (unit) {
                case "KB" -> size * 1024;
                case "MB" -> size * 1024 * 1024;
                case "GB" -> size * 1024 * 1024 * 1024;
                default -> 0;
            };
        }
    }

    @Bean(name = "RunningInDocker")
    public boolean runningInDocker() {
        return Files.exists(Paths.get("/.dockerenv"));
    }

    @Bean(name = "configDirMounted")
    public boolean isRunningInDockerWithConfig() {
        Path dockerEnv = Paths.get("/.dockerenv");
        // default to true if not docker
        if (!Files.exists(dockerEnv)) {
            return true;
        }
        Path mountInfo = Paths.get("/proc/1/mountinfo");