Skip to content

Fixup KAFKA-3160: catch decompression errors in constructor#1344

Closed
dpkp wants to merge 2 commits intoapache:trunkfrom
dpkp:decompress_error_code
Closed

Fixup KAFKA-3160: catch decompression errors in constructor#1344
dpkp wants to merge 2 commits intoapache:trunkfrom
dpkp:decompress_error_code

Conversation

@dpkp
Copy link
Copy Markdown
Contributor

@dpkp dpkp commented May 9, 2016

After testing KAFKA-3160 a bit more, I found that the error code was not being set properly in ProduceResponse. This happened because the validation error is raised in the CompressionFactory constructor, which was not wrapped in a try / catch.

@ijuma @junrao

(This contribution is my original work and I license the work under Apache 2.0.)

@ijuma
Copy link
Copy Markdown
Member

ijuma commented May 9, 2016

Thanks for the PR @dpkp. Would it be possible to add a test for this?

new DataInputStream(CompressionFactory(wrapperMessage.compressionCodec, wrapperMessage.magic, inputStream))
} catch {
case ioe: IOException =>
throw new CorruptRecordException(ioe)
Copy link
Copy Markdown
Member

@ijuma ijuma May 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird to throw an ApiException (CorruptRecordException is a subclass) from here, I think. Let's see what @junrao thinks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine since we already throw CorruptRecordException in line 116 in this class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, but that line was added as part of the LZ4 PR. I think we have to use InvalidMessageException in both places for compatibility with older clients. The scaladoc for InvalidMessageException says:

* Indicates that a message failed its checksum and is corrupt
 *
 * InvalidMessageException extends CorruptRecordException for temporary compatibility with the old Scala clients.
 * We want to update the server side code to use and catch the new CorruptRecordException.
 * Because ByteBufferMessageSet.scala and Message.scala are used in both server and client code having
 * InvalidMessageException extend CorruptRecordException allows us to change server code without affecting the client.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpkp, can you please make the change above?

@ijuma
Copy link
Copy Markdown
Member

ijuma commented May 9, 2016

@dpkp I created a PR (dpkp#2) with a test and the exception changes I suggested. Can you please review and integrate if you agree?

@ijuma
Copy link
Copy Markdown
Member

ijuma commented May 9, 2016

The next RC is meant to go out this morning, so we need to get this merged ASAP.

@dpkp dpkp force-pushed the decompress_error_code branch from 77e8e46 to b02502a Compare May 9, 2016 17:29
@dpkp
Copy link
Copy Markdown
Contributor Author

dpkp commented May 9, 2016

Sorry, offline last night / this a.m. I merged in your changes, @ijuma . Thanks!!

@ijuma
Copy link
Copy Markdown
Member

ijuma commented May 9, 2016

LGTM.

Thanks @dpkp for catching this in the first place and for merging the PR. Gwen reviewed by PR, so I'll go ahead and merge this as soon as the tests pass.

@asfgit asfgit closed this in 4331bf4 May 9, 2016
asfgit pushed a commit that referenced this pull request May 9, 2016
After testing KAFKA-3160 a bit more, I found that the error code was not being set properly in ProduceResponse. This happened because the validation error is raised in the CompressionFactory constructor, which was not wrapped in a try / catch.

ijuma junrao

(This contribution is my original work and I license the work under Apache 2.0.)

Author: Dana Powers <dana.powers@gmail.com>
Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Jun Rao <junrao@gmail.com>, Gwen Shapira <cshapi@gmail.com>, Ismael Juma <ismael@juma.me.uk>

Closes #1344 from dpkp/decompress_error_code

(cherry picked from commit 4331bf4)
Signed-off-by: Ismael Juma <ismael@juma.me.uk>
gfodor pushed a commit to AltspaceVR/kafka that referenced this pull request Jun 3, 2016
After testing KAFKA-3160 a bit more, I found that the error code was not being set properly in ProduceResponse. This happened because the validation error is raised in the CompressionFactory constructor, which was not wrapped in a try / catch.

ijuma junrao

(This contribution is my original work and I license the work under Apache 2.0.)

Author: Dana Powers <dana.powers@gmail.com>
Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Jun Rao <junrao@gmail.com>, Gwen Shapira <cshapi@gmail.com>, Ismael Juma <ismael@juma.me.uk>

Closes apache#1344 from dpkp/decompress_error_code
jsancio pushed a commit to jsancio/kafka that referenced this pull request Aug 6, 2019
Conflicts:
GroupCoordinatorIntegrationTest.scala - line 50
SocketServerTest.scala - TestableSocketServer class, removed verifyAcceptorIdlePercent() method, apache#1301 removed pollBlockMs var used in apache#1344 poll() method; testConnectionRateLimit() method changed
SocketServer.scala - apache#82, removed SocketServerMetricsGroup var, apache#455 removed idlePercentMeter
KafkaApis.scala - apache#50 imports
RequestQuotaTest.scala - apache#28 imports
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

Successfully merging this pull request may close these issues.

3 participants