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

multi-byte message fails to send #46

Open
GoogleCodeExporter opened this issue Aug 4, 2015 · 1 comment
Open

multi-byte message fails to send #46

GoogleCodeExporter opened this issue Aug 4, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. create a message payload with multi-byte text, over the maximum amount of 
characters allowed for the message (512 bytes)
2. try to send it

What is the expected output? What do you see instead?
com.googlecode.jsendnsca.NagiosException: Error occurred while sending passive 
alert
        at com.googlecode.jsendnsca.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:95)
        at com.gsm.nsca.Alerter$AlertSender.process(Alerter.java:553)
        at com.gsm.lib.BatchRunner.processElements(BatchRunner.java:316)
        at com.gsm.lib.BatchRunner.flushBatch(BatchRunner.java:164)
        at com.gsm.lib.BatchRunner.run(BatchRunner.java:87)

Caused By: java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at com.googlecode.jsendnsca.utils.ByteArrayUtils.getFixedSizeBytes(ByteArrayUtils.java:98)
        at com.googlecode.jsendnsca.utils.ByteArrayUtils.writeFixedString(ByteArrayUtils.java:44)
        at com.googlecode.jsendnsca.PassiveCheckBytesBuilder.writeFixedString(PassiveCheckBytesBuilder.java:88)
        at com.googlecode.jsendnsca.PassiveCheckBytesBuilder.withMessage(PassiveCheckBytesBuilder.java:61)
        at com.googlecode.jsendnsca.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:80)
        at com.gsm.nsca.Alerter$AlertSender.process(Alerter.java:553)
        at com.gsm.lib.BatchRunner.processElements(BatchRunner.java:316)
        at com.gsm.lib.BatchRunner.flushBatch(BatchRunner.java:164)
        at com.gsm.lib.BatchRunner.run(BatchRunner.java:87)

What version of the product are you using? On what operating system?
2.0.1

Please provide any additional information below.

ByteArratUtils.getFixedSizeBytes() is broken.
At first, it uses character length to cap the string to maximum bytes allowed, 
but then uses byte length to copy the string into the array.

Considering that it would be as bad to convert the string into the array, and 
then cut it (as it can cut through a multi-byte character), it may be best to 
estimate using the character length first, and then keep dropping characters 
from the end until the byte length is satisfied. I don't know of any tricks 
that would make it more efficient.

Original issue reported on code.google.com by [email protected] on 27 Feb 2014 at 6:58

@GoogleCodeExporter
Copy link
Author

Sounds like a genuine one.

If you are using NSCA version 2.9.1+ which supports 4096 characters, as a 
workaround you can enable long message support in JSendNSCA 2.1-RC1 as below

MessagePayload messagePayload = new MessagePayloadBuilder()
    .withSupportForLargeMessages()
...
    .create();

Meanwhile, will work on a fix for this.

Original comment by rajneeshpatel on 27 Feb 2014 at 9:21

  • Changed state: Accepted

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

No branches or pull requests

1 participant