Smell of Code 304: Excluding an empty indicator โ how to avoid empty references that cause operating time to collapse

I am still writing about empty problems, however, the news reminds me every day: Null is still alive and kicking.
TL; DR: Avoid empty references that cause operating time accidents using health verification patterns and empty patterns
Problems 
In the case of Google Cloud:
- Poor error treatment: The symbol was shattered instead of dealing with empty data safely
- There are no feature flags: No new code has been published gradually with safety control tools
- Immediately global symmetric copies: bad data is spread all over the world immediately, as is the case in the Crowdstrike incident
- There is no random decline: the recovery caused an increase in pregnancy
- The insufficient test: The failure scenario was not tested during the publication
Solutions 
- Avoid
- Use empty tests if empty is outside your control (for example, an external application programming interface)
- Create virtual values
- Implementing the items of the guards
- Use empty objects
- Do not use choices
Refactorings 
https://haackernoon.com/code-refactoring-tips-no-015-remove-nll
Context 
On June 12, 2025, a significant interruption occurred on the Google Cloud platform.
It affected dozens of Google Cloud and Google Workspace Services services worldwide from around 10:49 am to 1:49 PM PDT (a total of 3 hours), with some services excluded longer to recover completely.
The reason for the power outage was a consecutive failure in the Google Applications Management System:
On May 29, 2025, Google has published a new symbol of โservice controlโ (their application programming system management system) that added additional shares policy checks.
This symbol had a critical defect. He lacked the tackle of appropriate errors and was not protected by feature flags.
On June 12, changing a policy containing empty/void The fields have been pushed to the global database that you use to control the service. When I tried to control the service, treat these empty fields, she faced an empty indicator of the unprotected code path, which led to the disruption of the diodes in an endless ring.
Since the shares management is universal, this damaged data has been repeated all over the world within seconds, causing service control in each region.
Expectations are empty indicator when trying to reach methods or properties on the non -existent organisms.
This happens when the variables contain empty references instead of an oral object.
The problem becomes particularly dangerous in production environments, as these exceptions can disrupt your application and frustrate users.
Languages โโsuch as Java, C#and Javascript are particularly vulnerable to this problem, although modern language features and patterns can help you avoid these accidents completely.
Nulls has been a big problem in the software industry for decades, however software engineers have continued to ignore them despite their creator warnings.
Code 
Error 
public class ServiceControlPolicy {
private SpannerDatabase spannerDB;
private QuotaManager quotaManager;
public void applyPolicyChange(PolicyChange change) {
// NULL POINTER: change can be null
Policy policy = spannerDB.getPolicy(change.getPolicyId());
// NULL POINTER: policy can be null from the database
String quotaField = policy.getQuotaField();
// NULL POINTER: quotaField can be null (blank field)
quotaManager.updateQuota(quotaField, change.getValue());
}
public void exerciseQuotaChecks(String region) {
// NULL POINTER: policies list can be null
List policies = spannerDB.getPoliciesForRegion(region);
for (Policy policy : policies) {
// NULL POINTER: individual policy can be null
String quotaValue = policy.getQuotaField();
// NULL POINTER: quotaValue can be null before trim()
quotaManager.checkQuota(quotaValue.trim());
}
}
public boolean validatePolicyData(Policy policy) {
// NULL POINTER: policy parameter can be null
String quotaField = policy.getQuotaField();
// NULL POINTER: quotaField can be null before length()
return quotaField.length() > 0 &&
!quotaField.equals("null");
}
public void replicateGlobally(PolicyChange change) {
List regions = getGlobalRegions();
for (String region : regions) {
// NULL POINTER: change.getPolicy() can return null
spannerDB.insertPolicy(region, change.getPolicy());
}
}
}
Right 
public class ServiceControlPolicy {
private SpannerDatabase spannerDB;
private QuotaManager quotaManager;
public void applyPolicyChange(PolicyChange change) {
if (change == null) {
// Assuming it comes from an external API
// Beyond your control
change = new NullPolicyChange();
}
Policy policy = findPolicyOrNull(change.policyId());
String quotaField = policy.quotaField();
if (!quotaField.isEmpty()) {
quotaManager.updateQuota(quotaField, change.value());
}
}
public void exerciseQuotaChecks(String region) {
if (region == null || region.isEmpty()) {
// Assuming it comes from an external API
// Beyond your control
return;
}
List policies = policiesOrEmpty(region);
for (Policy policy : policies) {
String quotaValue = policy.quotaField();
if (!quotaValue.isEmpty()) {
quotaManager.checkQuota(quotaValue.trim());
}
}
}
public boolean validatePolicyData(Policy policy) {
if (policy == null) {
// Assuming it comes from an external API
// Beyond your control
// From now on, you wrap it
policy = new NullPolicy();
}
String quotaField = policy.quotaField();
return quotaField.length() > 0;
}
public void replicateGlobally(PolicyChange change) {
if (change == null) {
// Assuming it comes from an external API
// Beyond your control
// From now on, you wrap it
change = new NullPolicyChange();
}
Policy policy = change.policy();
if (policy == null) {
// Assuming it comes from an external API
// Beyond your control
// From now on, you wrap it
policy = new NullPolicy();
}
List regions = globalRegions();
for (String region : regions) {
spannerDB.insertPolicy(region, policy);
}
}
private Policy findPolicyOrNull(String policyId) {
Policy policy = spannerDB.policy(policyId);
return policy != null ? policy : new NullPolicy();
}
private List policiesOrEmpty(String region) {
List policies = spannerDB.policiesForRegion(region);
if (policies == null) {
// This is a good NullObject
return Collections.emptyList();
}
return policies.stream()
.map(p -> p != null ? p : new NullPolicy())
.collect(Collectors.toList());
}
}
class NullPolicy extends Policy {
@Override
public String quotaField() { return ""; }
@Override
public String policyId() { return "unknown-policy"; }
@Override
public Map metadata() {
return Collections.emptyMap();
}
}
class NullPolicyChange extends PolicyChange {
@Override
public String policyId() { return ""; }
@Override
public String value() { return ""; }
@Override
public Policy policy() { return new NullPolicy(); }
}
Detection 
You can discover the potential Null indexโs exceptions by reviewing the software instructions for the direct method of the objects without empty checks.
Pesticides can check the values โโof return from the ways that may return voidLooking for unpleasant object fields, and using fixed analysis tools that indicate potential sculpture removal.
Modern IDES often highlights these issues with warnings.
Level 
Why the objection is important 
In the real world, things are either or not.
When you design this properly in the program, you can create clear correspondence between reality and symbol.
Breaking this vital objection by allowing empty references creates the Phantom beings in your code but not in the real world, which leads to accidents when you try to interact with these non -existent entities.
If you choose the Null Licensing Panel, you will get a lot of parking tickets
Amnesty International Generation 
AI generators often create an empty indicator weakening points as they focus on the HAPPY PHTH scenarios.
They often create way calls without looking at the edge situations in which creatures may be voidEspecially in the hierarchical serials of complex organisms or when dealing with external data sources.
Discover artificial intelligence 
Artificial intelligence tools can discover and repair empty indicator problems when providing clear instructions on defensive programming practices.
Try them! 
Remember: Artificial Intelligence Assistants make many mistakes
A proposal wave: remove all empty references
Conclusion 
The NULL index exceptions are one of the most common programming time errors.
You can remove most of these incidents by carrying out the appropriate empty checks, using the style of empty object design, and adopting defensive programming practices.
The small general expenditures of the health verification code greatly pay the fruits in the stability of the application and the user experience.
Relationships
โ
https://haackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-iii-t7h3zkv
https://haackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xliii
https://haackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxxx
https://haackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxvi
https://haackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xlii
More information 
Leave responsibility 
The smell of the code is my opinion.
I call it my fault by billions of dollars. The invention of the empty reference was in 1965
Tony Hark
This article is part of the Codesmell series.