{"record":{"id":"323ef45845505fe3","repo":"bumptech/glide","slug":"must-not-be-null-or-empty","errorCode":null,"errorMessage":"Must not be null or empty","messagePattern":"Must not be null or empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/util/Preconditions.java","lineNumber":41,"sourceCode":"  }\n\n  @NonNull\n  public static <T> T checkNotNull(@Nullable T arg) {\n    return checkNotNull(arg, \"Argument must not be null\");\n  }\n\n  @NonNull\n  public static <T> T checkNotNull(@Nullable T arg, @NonNull String message) {\n    if (arg == null) {\n      throw new NullPointerException(message);\n    }\n    return arg;\n  }\n\n  @NonNull\n  public static String checkNotEmpty(@Nullable String string) {\n    if (TextUtils.isEmpty(string)) {\n      throw new IllegalArgumentException(\"Must not be null or empty\");\n    }\n    return string;\n  }\n\n  @NonNull\n  public static <T extends Collection<Y>, Y> T checkNotEmpty(@NonNull T collection) {\n    if (collection.isEmpty()) {\n      throw new IllegalArgumentException(\"Must not be empty.\");\n    }\n    return collection;\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":54,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/util/Preconditions.java#L23-L54","documentation":"Thrown by Preconditions.checkNotEmpty(String) when the string is null or empty (TextUtils.isEmpty). This is Glide's internal null/empty guard used at the boundary of many APIs (URLs, keys, headers). Preconditions is not part of the public API surface but its exceptions surface to callers who pass bad string arguments to public methods that delegate to it.","triggerScenarios":"Passing a null or empty String where Glide requires a non-empty one: a null URL/key, an empty cache key override, an empty signature, an empty model string for asString().load().","commonSituations":"Loading from a nullable field (e.g. JSON-parsed URL) without a null check; an empty EditText URL submitted by the user; a data model whose image URL field is unset.","solutions":["Null/empty-check the string before calling Glide: if (!url.isNullOrEmpty()) Glide.with(ctx).load(url)...","Provide a fallback via .error(drawable) or skip the load entirely when the URL is missing","Annotate your own data fields @Nullable and handle both states explicitly","Use Kotlin's url?.let { Glide.with(ctx).load(it) } ?: showPlaceholder()"],"exampleFix":"// before\nGlide.with(ctx).load(item.imageUrl).into(imageView) // imageUrl may be null/\"\"\n\n// after\nif (!item.imageUrl.isNullOrEmpty()) {\n  Glide.with(ctx).load(item.imageUrl).into(imageView)\n} else {\n  imageView.setImageResource(R.drawable.placeholder)\n}","handlingStrategy":"validation","validationCode":"fun loadUrl(url: String?) {\n  if (url.isNullOrEmpty()) {\n    imageView.setImageResource(R.drawable.placeholder)\n    return\n  }\n  Glide.with(ctx).load(url).into(imageView)\n}","typeGuard":"fun isValidModel(s: String?): Boolean = !s.isNullOrEmpty()","tryCatchPattern":null,"preventionTips":["Null/empty-check all string models before passing them to Glide","Annotate data-model URL fields @Nullable and handle both branches","Use Kotlin url?.let { ... } ?: showPlaceholder() to make the null branch explicit"],"tags":["android","glide","validation","null-check","preconditions"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}