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

buffer and slice #143

Closed
DavidApfel opened this issue Jan 27, 2016 · 2 comments
Closed

buffer and slice #143

DavidApfel opened this issue Jan 27, 2016 · 2 comments

Comments

@DavidApfel
Copy link

Not sure if this is a bug or just different behaviour than with node, but when using for example the bn.js module with trireme it's a problem.

When using trireme and create a buffer and try to get a minus index [-1] of the buffer it gives an ArrayIndexOutOfBoundsException. When I create then a second buffer with slice() from the first buffer and then try to get a minus index it gives a value. While using node I get undefined in both cases:

var buf1 = new Buffer("1111", "hex");
var buf2 = buf1.slice(1);

trireme:

console.log(buf1[-1]); // java.lang.ArrayIndexOutOfBoundsException: -1
console.log(buf2[-1]); // 17

node:

console.log(buf1[-1]); // undefined
console.log(buf2[-1]); // undefined
@gbrail
Copy link
Contributor

gbrail commented Jan 29, 2016

Thanks for trying this. If trireme works differently from Node 0.10 in this
regard then it's a Trireme bug that wasn't caught by one of the regression
tests. This should not be too hard to fix...

On Wed, Jan 27, 2016 at 10:09 AM, DavidApfel notifications@github.com
wrote:

Not sure if this is a bug or just different behaviour than with node, but
when using for example the bn.js module with trireme it's a problem.

When using trireme and create a buffer and try to get a minus index [-1]
of the buffer it gives an ArrayIndexOutOfBoundsException. When I create
then a second buffer with slice() from the first buffer and then try to get
a minus index it gives a value. While using node I get undefined in both
cases:

var buf1 = new Buffer("1111", "hex");
var buf2 = buf1.slice(1);

trireme:

console.log(buf1[-1]); // java.lang.ArrayIndexOutOfBoundsException: -1
console.log(buf2[-1]); // 17

node:

console.log(buf1[-1]); // undefined
console.log(buf2[-1]); // undefined


Reply to this email directly or view it on GitHub
#143.

Greg Brail | apigee https://apigee.com/ | twitter @gbrail
http://twitter.com/gbrail @apigee https://twitter.com/apigee

@DavidApfel
Copy link
Author

Yes, Trireme works differently from Node v0.10.32. Thanks!

whitlockjc added a commit to whitlockjc/trireme that referenced this issue Sep 22, 2017
Prior to this change, when accessing a Buffer with a negative index, a
Java error (java.lang.ArrayIndexOutOfBoundsException) was thrown instead
of returning `undefined` per standard node.js functionality.

Fixes apigee#143
gbrail pushed a commit that referenced this issue Sep 25, 2017
Prior to this change, when accessing a Buffer with a negative index, a
Java error (java.lang.ArrayIndexOutOfBoundsException) was thrown instead
of returning `undefined` per standard node.js functionality.

Fixes #143
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

No branches or pull requests

2 participants