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

Fixed concurrency issue in ObjectDeserializer #449

Merged
merged 5 commits into from
May 15, 2023
Merged

Conversation

msupic
Copy link
Contributor

@msupic msupic commented May 12, 2023

No description provided.

@graemerocher graemerocher marked this pull request as draft May 12, 2023 13:34
@graemerocher
Copy link
Contributor

stack overflows so probably not the solution

@dstepanov
Copy link
Contributor

I will try to fix it

@timyates
Copy link
Contributor

@dstepanov I'm likely wrong, but could the fix be:

    @Override
    public <T> DeserBean<T> getDeserializableBean(Argument<T> type, DecoderContext decoderContext) throws SerdeException {
        TypeKey key = new TypeKey(type);
        DeserBean<T> deserBeanSupplier = (DeserBean) deserBeanMap.get(key);
        if (deserBeanSupplier == null) {
            synchronized (deserBeanMap) { // double check
                deserBeanSupplier = (DeserBean) deserBeanMap.get(key);
                if (deserBeanSupplier == null) {
                    deserBeanSupplier = createDeserBean(type, decoderContext);
                    deserBeanMap.put(key, (DeserBean) deserBeanSupplier);
                    deserBeanSupplier.initialize(decoderContext);
                }
            }
        }
        return deserBeanSupplier;
    }

?

@yawkat
Copy link
Member

yawkat commented May 15, 2023

@timyates no, there is still a data race between the put and the unguarded get in that fix. put must come after the initialize somehow

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@dstepanov
Copy link
Contributor

@graemerocher Fixed

@dstepanov dstepanov marked this pull request as ready for review May 15, 2023 14:17
@graemerocher graemerocher merged commit 506756d into master May 15, 2023
@graemerocher graemerocher deleted the concurrency_issue branch May 15, 2023 14:18
@graemerocher graemerocher added the type: bug Something isn't working label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants