Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
import com.yarolegovich.wellsql.core.annotation.PrimaryKey;
import com.yarolegovich.wellsql.core.annotation.RawConstraints;
import com.yarolegovich.wellsql.core.annotation.Table;

import org.wordpress.android.fluxc.Payload;
import org.wordpress.android.fluxc.model.LocalOrRemoteId.LocalId;
import org.wordpress.android.fluxc.model.LocalOrRemoteId.RemoteId;
Expand All @@ -26,6 +20,12 @@
import java.util.Arrays;
import java.util.Objects;

import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
import com.yarolegovich.wellsql.core.annotation.PrimaryKey;
import com.yarolegovich.wellsql.core.annotation.RawConstraints;
import com.yarolegovich.wellsql.core.annotation.Table;

// WARN: This class is used within WordPress-MediaPicker-Android, do not remove!
@Table
@RawConstraints({"UNIQUE (SITE_ID, URL)"})
Expand Down Expand Up @@ -1110,7 +1110,7 @@ public void setPublishedStatus(int publishedStatus) {
}

public Boolean getCanBlaze() {
return mCanBlaze;
return mCanBlaze == true;
Copy link
Member

@hichamboushaba hichamboushaba Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not enough for the fix, we just moved the NPE exception here instead of IsBlazeEnabled.

When unboxing from the Boolean type to the primitive type, we'll get an NPE, and to reproduce it just comment the this.mCanBlaze = canBlaze; in the line 1117 to make sure we keep the default value (simulating what would happen if options is missing from /me/sites response), the app will crash with the following exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
                                                                                                    	at org.wordpress.android.fluxc.model.SiteModel.getCanBlaze(SiteModel.java:1113)
                                                                                                    	at com.woocommerce.android.ui.blaze.IsBlazeEnabled.invoke(IsBlazeEnabled.kt:25)

If we want to keep the Boolean class as type, we need to improve this check to something like:

Suggested change
return mCanBlaze == true;
return mCanBlaze != null && mCanBlaze;

}

public void setCanBlaze(Boolean canBlaze) {
Expand Down
Loading