[
https://issues.apache.org/jira/browse/AVRO-3590?focusedWorklogId=795669&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-795669
]
ASF GitHub Bot logged work on AVRO-3590:
----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Jul/22 14:12
Start Date: 27/Jul/22 14:12
Worklog Time Spent: 10m
Work Description: clesaec commented on code in PR #1790:
URL: https://github.com/apache/avro/pull/1790#discussion_r931115882
##########
lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java:
##########
@@ -37,7 +40,7 @@ static class Option extends CodecFactory {
@Override
protected Codec createInstance() {
- return new SnappyCodec();
+ return SnappyCodec.INSTANCE;
Review Comment:
Hello,
A comment and a question :
As SnappyCodec contains a crc32 field that change [its state on Compress
call](https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java#L57-L58),
usage of a singleton will lead to error in multi thread environment.
On your issue, do you have any log that contains "Snappy was not available".
That could explain why "snappy" is null [with this
code](https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/file/CodecFactory.java#L68-L72)
?
Issue Time Tracking
-------------------
Worklog Id: (was: 795669)
Time Spent: 20m (was: 10m)
> Fix the problem that CodeFactory is null when specifying snappy format when
> java Client compresses data
> -------------------------------------------------------------------------------------------------------
>
> Key: AVRO-3590
> URL: https://issues.apache.org/jira/browse/AVRO-3590
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.10.0
> Reporter: xingyuan cheng
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.10.0
>
> Attachments: image-2022-07-27-16-10-17-970.png,
> image-2022-07-27-16-10-33-410.png, image-2022-07-27-16-10-42-262.png,
> image-2022-07-27-16-11-46-218.png
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> When flink-avro writes data in batches based on the avro format, the general
> user will specify snappy compression. However, in the avro-1.10.0 version,
> the Codec and CodeFactory are returned by directly applying for the object,
> so that the user cannot obtain it Information for SnappyCodec.
> I refer to the practice of ```NullCodec```, changing it to a global variable
> way will work fine
>
> !image-2022-07-27-16-10-17-970.png!
>
> Before repair:
> !image-2022-07-27-16-10-42-262.png!
>
>
> after Repair:
>
> !image-2022-07-27-16-11-46-218.png!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)