Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.nullability

Check Optional before calling get

Optional.get without a presence check can throw.

#Metadata

Rule ID
java.correctness.unsafe-optional-get
Severity
medium
Confidence
0.88
Languages
java
Presets
strict
Stability
stable
Applies to
block
Tags
correctness, java, rules-catalog

#Why it matters

Unchecked Optional access causes runtime failures.

#Remediation

Use orElse, orElseThrow, or isPresent before calling get.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/java/java.correctness.unsafe-optional-get.rule.yaml.