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

SNMP trap number value cast exception #298

Closed
nmaguiar opened this issue Aug 13, 2021 · 0 comments
Closed

SNMP trap number value cast exception #298

nmaguiar opened this issue Aug 13, 2021 · 0 comments

Comments

@nmaguiar
Copy link
Collaborator

Description
Whenever sending a SNMP trap with an object of type "integer" there are cases where the following exception can occur:

Error while executing operation: Wrapped java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

How to reproduce
Just try to send a number 1 or number 5, for example:

function sendTrap(aSNMPObject, aOID, anEntry) {
   aSNMPObject.trap(aOID, [
     { OID: anEntry.oid, type: anEntry.type, value: anEntry.value }
  ], false);
}

var myValue = 5;
sendTrap({ OID: myOID, type: "i", value: myValue })  // No exception
myValue = 1
sendTrap({ OID: myOID, type: "i", value: myValue })  // Exception might occur

Expected behavior
With either value 1 or 5 the javascript to java conversion should work but it seems a Rhino issue. Or, at least, the sendTrap function should cast from Double to Integer if needed internally.

Workaround
Using the "How to reproduce" code above just force the java type conversion:

sendTrap({ OID: myOID, type: "i", value: java.lang.Integer.valueOf(myValue) })
@nmaguiar nmaguiar added this to Backlog in Continuous Enhancement via automation Aug 13, 2021
Continuous Enhancement automation moved this from Backlog to Done Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant