Skip to content

Investigate on the issue and the solution proposed about exceptions raised #856

@masesdevelopers

Description

@masesdevelopers

Looking at masesgroup/KEFCore#448 and analyzing the code:
https://github.com/masesgroup/KNet/blob/024d22b6e15a7fd2725b4b83d563cb742d9dfa90/src/jvm/knet/src/main/java/org/mases/knet/generated/org/apache/kafka/streams/processor/TimestampExtractor.java#L73-L77

  • the first issue is related to a missing assignment of the return value in the JNetEventResult: the default null is returned back and the unboxing conversion fails raising java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because "retVal" is null
  • the second issue is related to a similar condition since the function getHasOverride probably returns the default value which is false

The JNetEventResult instance is created locally and the extract method invokes the synchronized method https://github.com/masesgroup/KNet/blob/024d22b6e15a7fd2725b4b83d563cb742d9dfa90/src/jvm/knet/src/main/java/org/mases/knet/generated/org/apache/kafka/streams/processor/TimestampExtractor.java#L45-L48

The code of JNetEventResult is very simple:

public class JNetEventResult {
   boolean _hasOverride = false;
   Object _returnData;

   public boolean getHasOverride() {
      return _hasOverride;
   }

   public void setHasOverride(boolean hasOverride) {
      _hasOverride = hasOverride;
   }

   public Object getReturnData() {
      return _returnData;
   }

   public void setReturnData(Object retData) {
      _returnData = retData;
   }
   
   public void setReturnData(boolean hasOverride, Object retData) {
      _hasOverride = hasOverride;
      _returnData = retData;
   }
}

but for the second issue seems clear that the default value is returned from getHasOverride.
Maybe it can be an option to replace the _hasOverride field with a type that accept to be a three state or verify if the value was returned adding an extra field updated when setReturnData or setHasOverride are invoked: if the optional boolean field is still false the getHasOverride can raise an internal exception since no one updated its internal value.
Shall be checked if the method setReturnData with one parameter is in use: otherwise the one with two parameter can change its name to avoid method matching confusion, leaving the value of _hasOverride to its default value.
Anyway an update on JNet shall be made to verify the previous assumptions.

Originally posted by @masesdevelopers in #1058

Sub-issues

Metadata

Metadata

Labels

JNetJNet related issuejavaPull requests that update Java code

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions