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

Client crashes if app adds any functions to Array.prototype (or Object.prototype) #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ module.exports = std.Class(Connection, function(supr) {
// send queued send requests
// make a copy because socket writes may return immediately and modify the size
var r = this._sendRequests.slice(0);
for (i in r) this._writeRequest(r[i])
for (var i=0; i<r.length; i++) this._writeRequest(r[i])
// send queued read requests
for (i in this._requests) this._writeRequest(this._requests[i])
for (var i=0; i<this._requests.length; i++) this._writeRequest(this._requests[i])
}

this._pushSendRequest = function(requestObj) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = std.Class(Client, function(supr) {
}

this.unsubscribeTopic = function(name) {
for (i in this._topics) if (this._topics[i].name == name) {
for (var i=0; i<this._topics.length; i++) if (this._topics[i].name == name) {
this._topics.splice(i, 1)
break
}
Expand Down Expand Up @@ -80,14 +80,14 @@ module.exports = std.Class(Client, function(supr) {
if (this._outstanding > 0 || !this._timerTicked) return

this._timerTicked = false
for (i in this._topics) {
for (var i=0; i<this._topics.length; i++) {
this._outstanding++
this.fetchTopic(this._topics[i])
}
}

this._processMessage = function(topic, message, offset) {
for (i in this._topics) if (this._topics[i].name == topic) {
for (var i=0; i<this._topics.length; i++) if (this._topics[i].name == topic) {
this.emit('debug', "_processMessage is setting new offset for topic:" + topic + " offset: " + offset)
this._topics[i].offset = offset
break
Expand All @@ -96,7 +96,7 @@ module.exports = std.Class(Client, function(supr) {

this._processLast = function(topic, offset, errno, error) {
if (false && Math.random()*100 > 90) {
for (i in this._topics) if (this._topics[i].name == topic) {
for (var i=0; i<this._topics.length; i++) if (this._topics[i].name == topic) {
console.log("INJECTING ERRONEOUS OFFSET TO TOPIC: " + topic + " OFFSET: " + (offset-1000))
this._topics[i].offset = offset - 1000
break
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "kafka",
"description": "A node client for Kafka",
"version": "0.1.7",
"homepage": "https://github.com/marcuswestin/node-kafka",
"name": "kafka-fork",
"description": "A node client for Kafka. My fork with a fix for #5, since I couldn't wait for pull request for too long",
"version": "0.1.8",
"homepage": "https://github.com/yankov/node-kafka",
"author": "Marcus Westin <[email protected]> (http://marcuswest.in)",
"repository": {
"type": "git",
Expand Down