Boxed value is unboxed and then immediately reboxed

Viewed 7829

I am solving SonarQube issues , in that issues i face an bellow error but can not understant what kind of error is this ,

Here is my entity class

@Entity
@Cacheable
@DynamicUpdate
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table(name = Vendor.TABLE_NAME)
public class Vendor 
{


    @Column(name = VENDOR_MODIFIED_BY_FOREIGN_KEY, nullable = true)

    private Integer modifiedBy;



    public Integer getModifiedBy() {

        return modifiedBy == null ? 0 : modifiedBy;

//Boxed value is unboxed and then immediately reboxed in com.bostonbyte.thelift.entities.vendors.Vendor.getModifiedBy() 




    }



    public void setModifiedBy(Integer modifiedBy) {

        this.modifiedBy = modifiedBy;

    }

I get an error at

 public Integer getModifiedBy() {

                return modifiedBy == null ? 0 : modifiedBy;

Could you please let me know what kind of error is this?

4 Answers

Had the same similar issue with Boolean.

return isModified == null? false : defValue

changed to:

return isModified == null? Boolean.valueOf(false) : defValue
Related