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

[KOGITO-7959]-Handling Null pointer in Models class if write method does not exist #2620

Closed
wants to merge 1 commit into from

Conversation

VaniHaripriya
Copy link
Contributor

Jira - https://issues.redhat.com/browse/KOGITO-7959

Handled the possible null pointer exception while accessing the write method in Models class.

@sonarcloud
Copy link

sonarcloud bot commented Nov 16, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@kie-ci3
Copy link
Contributor

kie-ci3 commented Nov 16, 2022

(tests) - kogito-runtimes job #1473 was: UNSTABLE
Possible explanation: This should be test failures

Please look here: https://eng-jenkins-csb-business-automation.apps.ocp-c1.prod.psi.redhat.com/job/KIE/job/kogito/job/main/job/pullrequest/job/kogito-runtimes.tests.kogito-runtimes/1473/display/redirect

Test results:

  • PASSED: 3116
  • FAILED: 1

Those are the test failures:

org.kie.kogito.codegen.tests.VariableIT.testVariablesWithReservedNameOnServiceTask org.kie.kogito.ReflectiveModelAccessException: java.beans.IntrospectionException: Method not found: isPackage
at org.kie.kogito.codegen.tests.VariableIT.testVariablesWithReservedNameOnServiceTask(VariableIT.java:43)
Caused by: java.beans.IntrospectionException: Method not found: isPackage
at org.kie.kogito.codegen.tests.VariableIT.testVariablesWithReservedNameOnServiceTask(VariableIT.java:43)

@@ -77,8 +78,10 @@ public static <T> T fromMap(T m, Map<String, Object> map) {
for (Map.Entry<String, PropertyDescriptor> e : descriptors.entrySet()) {
String k = e.getKey();
k = unprefixVar(k);
PropertyDescriptor pd = new PropertyDescriptor(k, m.getClass());
Method writeMethod = pd.getWriteMethod();
Copy link
Contributor

@fjtirado fjtirado Nov 17, 2022

Choose a reason for hiding this comment

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

hmmm, e.getValue was already a property descriptor for key k, so I do not think this fixes the issue.
In order to determine that, you need to write a test that use a class without getter/setter but public fields

if (map.containsKey(k)) {
e.getValue().getWriteMethod().invoke(m, map.get(k));
writeMethod.invoke(m, map.get(k));
Copy link
Contributor

@fjtirado fjtirado Nov 17, 2022

Choose a reason for hiding this comment

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

I think this will still be null if there is not setter for that field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants