Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-14781712 fix: added null checks #143

Closed

Conversation

abbasmanthirik
Copy link
Contributor

Added null checks for token

Copy link

Thanks for the contribution! It looks like @abbasmanthirik is an internal user so signing the CLA is not required. However, we need to confirm this.

Copy link
Collaborator

@sahil-here sahil-here left a comment

Choose a reason for hiding this comment

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

We have a few queries:
Code Change related:

  1. Why a null check has been added here for W-14781712 where EntityFormulaContextBase.createMockFieldInfo is throwing the "IllegalArgumentException: entity Info is null"? How is this check related to that exception?
    Code Quality related:
  2. Why there is a need for the "else" block?
  3. Why the same check has not been added to the another constructor of the same class?
  4. Why has the datatype been updated from primitive to object for location and type? If yes, then does the getter/setter need to be updated or not, has that been considered?

@abbasmanthirik
Copy link
Contributor Author

We have a few queries: Code Change related:

  1. Why a null check has been added here for W-14781712 where EntityFormulaContextBase.createMockFieldInfo is throwing the "IllegalArgumentException: entity Info is null"? How is this check related to that exception?
    Code Quality related:
  2. Why there is a need for the "else" block?
  3. Why the same check has not been added to the another constructor of the same class?
  4. Why has the datatype been updated from primitive to object for location and type? If yes, then does the getter/setter need to be updated or not, has that been considered?
  1. The actual root cause for the gack is below from the stack trace link

`

Cause0: java.lang.NullPointerException
Cause0-StackTrace: at com.force.formula.impl.WrongArgumentTypeException.(WrongArgumentTypeException.java:23)at com.force.formula.impl.AnnotationVisitor.verifyInputs(AnnotationVisitor.java:114)at com.force.formula.impl.AnnotationVisitor.visit(AnnotationVisitor.java:82)at com.force.formula.impl.BaseFormulaInfoImpl.visitInorderIterative(BaseFormulaInfoImpl.java:746)at com.force.formula.impl.BaseFormulaInfoImpl.visit(BaseFormulaInfoImpl.java:732)at com.force.formula.impl.BaseFormulaInfoImpl.annotateAst(BaseFormulaInfoImpl.java:484)at com.force.formula.impl.BaseFormulaInfoImpl.(BaseFormulaInfoImpl.java:117)at common.formula.FormulaInfoImpl.(FormulaInfoImpl.java:61)at common.formula.FormulaInfoImpl.(FormulaInfoImpl.java:56)at common.formula.FormulaCoreFactory.create(FormulaCoreFactory.java:84)at com.force.formula.impl.FormulaInfoFactory.create(FormulaInfoFactory.java:89)at common.formula.template.FormulaTemplate.(FormulaTemplate.java:149)
`
  1. If those properties(location, type, text) are left uniinitialized without else block, there will be NPE furhter downstream
  2. Done
  3. Switched to primitive

@@ -64,8 +70,13 @@ public WrongArgumentTypeException(String function, Type[] expectedInputTypes, Fo

Token token = actual.getToken();
location = token.getColumn();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the "location" outside the null check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was a miss. Fixed it. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is the "location" outside the null check here?
Done

@sahil-here sahil-here closed this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants