{"record":{"id":"9c3a1cf429713d8d","repo":"quarkusio/quarkus","slug":"s-must-not-be-null","errorCode":null,"errorMessage":"`%s` must not be `null`","messagePattern":"`(.+?)` must not be `null`","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java","lineNumber":115,"sourceCode":"            throw new IllegalArgumentException(\"`\" + name + \"` must not be empty\");\n        }\n    }\n\n    static void validateLongitude(double longitude) {\n        if (longitude < -180 || longitude > 180) {\n            throw new IllegalArgumentException(\"The longitude must be in [-180, 180]\");\n        }\n    }\n\n    static void validateLatitude(double latitude) {\n        if (latitude < -85.05112878 || latitude > 85.05112878) {\n            throw new IllegalArgumentException(\"The latitude must be in [85.05112878, 85.05112878]\");\n        }\n    }\n\n    public static void validateTimeout(Duration value, String name) {\n        if (value == null) {\n            throw new IllegalArgumentException(String.format(\"`%s` must not be `null`\", name));\n        }\n        if (value.isNegative()) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be greater than or equal to zero\", name));\n        }\n    }\n\n    public static void positive(double amount, String name) {\n        if (amount <= 0) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be greater than zero`\", name));\n        }\n    }\n\n    public static void positiveOrZero(double amount, String name) {\n        if (amount < 0) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be greater or equal to zero\", name));\n        }\n    }\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java#L97-L133","documentation":"Validation.validateTimeout guards Duration arguments used by Redis commands with timeouts (e.g. wait, setex-style TTLs, blocking command timeouts). A null Duration cannot be converted to a Redis time value, so the datasource fails fast with IllegalArgumentException naming the offending parameter.","triggerScenarios":"Passing a null Duration to a Redis command that accepts a timeout/duration parameter, typically because a config property was absent and no default was applied, or a method returned Optional.empty().get-less null.","commonSituations":"Application configuration (e.g. quarkus.redis.timeout or a custom TTL property) not set so an injected field stays null; computing a Duration from a nullable timestamp difference; refactoring that dropped a default value like Duration.ofSeconds(5).","solutions":["Provide a non-null Duration, e.g. Duration.ofSeconds(5), at the call site","Give the config property a default value or mark it required so it is never null","Use Optional/Objects.requireNonNullElse to substitute a default: Objects.requireNonNullElse(cfg.ttl(), Duration.ZERO)","If zero is intended, pass Duration.ZERO explicitly (it passes this check; only negatives are rejected by the sibling branch)"],"exampleFix":"// before\nredis.set(key, value, SetArgs ex(ttl)); // ttl is null\n// after\nDuration ttl = Objects.requireNonNullElse(configuredTtl, Duration.ofSeconds(60));\nredis.set(key, value, SetArgs ex(ttl));","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(ttl, \"ttl must not be null\");\nDuration safe = Objects.requireNonNullElse(ttl, Duration.ofSeconds(60));","typeGuard":null,"tryCatchPattern":"try { redis.setTimeout(value); } catch (IllegalArgumentException e) { log.error(\"Invalid timeout: {}\", e.getMessage()); throw new ConfigurationException(e); }","preventionTips":["Give duration config properties defaults","Use Optional<Duration> and orElse a default","Never return null Duration from helper methods","Run tests with config absent to catch missing defaults"],"tags":["redis","validation","null-check","duration"],"backgroundTag":"null-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}