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

ConcurrentModificationException #59

Closed
howseen opened this issue Oct 22, 2023 · 2 comments · Fixed by #60
Closed

ConcurrentModificationException #59

howseen opened this issue Oct 22, 2023 · 2 comments · Fixed by #60
Assignees
Labels
bug Something isn't working

Comments

@howseen
Copy link

howseen commented Oct 22, 2023

Describe the bug

Seems you doesn't use a proper data structure for handling concurrent access to the list

Steps to reproduce the bug

No response

Expected behavior

No response

Logs, error output, etc.

java.util.ConcurrentModificationException: null
    at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:757)
    at java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:790)
    at java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:788)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFieldsUsing(SourceFile:902)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithoutTypeInfo(SourceFile:762)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(SourceFile:720)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(SourceFile:35)
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(SourceFile:728)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(SourceFile:774)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(SourceFile:178)
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(SourceFile:728)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(SourceFile:774)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(SourceFile:178)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(SourceFile:480)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(SourceFile:319)
    at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(SourceFile:4572)
    at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(SourceFile:3825)
    at io.getunleash.metrics.HttpMetricsReporter.reportMetrics(SourceFile:94)
    at io.getunleash.UnleashClient$special$$inlined$timer$1.run
    at java.util.TimerThread.mainLoop(Timer.java:562)
    at java.util.TimerThread.run(Timer.java:512)
    
    
com.fasterxml.jackson.databind.JsonMappingException: (was java.util.ConcurrentModificationException) (through reference chain: io.getunleash.metrics.Report["bucket"]->io.getunleash.metrics.Bucket["toggles"])
    at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(SourceFile:316)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(SourceFile:782)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(SourceFile:178)
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(SourceFile:728)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(SourceFile:774)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(SourceFile:178)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(SourceFile:480)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(SourceFile:319)
    at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(SourceFile:4572)
    at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(SourceFile:3825)
    at io.getunleash.metrics.HttpMetricsReporter.reportMetrics(SourceFile:94)
    at io.getunleash.UnleashClient$special$$inlined$timer$1.run
    at java.util.TimerThread.mainLoop(Timer.java:562)
    at java.util.TimerThread.run(Timer.java:512)

Screenshots

No response

Additional context

No response

Unleash version

0.5.5

Subscription type

Open source

Hosting type

Self-hosted

SDK information (language and version)

No response

@howseen howseen added the bug Something isn't working label Oct 22, 2023
@chriswk
Copy link
Member

chriswk commented Oct 24, 2023

Thank you @howseen for this bug report. I'll have a look today to see if I can't replace the list here with something more apt for concurrent modifications.

@chriswk chriswk self-assigned this Oct 24, 2023
chriswk added a commit that referenced this issue Oct 24, 2023
Since we're  continuously logging metrics, we could happen to log while
serializing the metrics bucket. Moving to a concurrenthashmap will allow
us to insert into the map while reading from the iterator.

fixes: #59
@chriswk chriswk linked a pull request Oct 24, 2023 that will close this issue
chriswk pushed a commit that referenced this issue Oct 25, 2023
Since we're  continuously logging metrics, we could happen to log while
serializing the metrics bucket. Moving to a concurrenthashmap will allow
us to insert into the map while reading from the iterator.

fixes: #59
@github-project-automation github-project-automation bot moved this from New to Done in Issues and PRs Oct 25, 2023
@chriswk
Copy link
Member

chriswk commented Oct 25, 2023

Hi @howseen - 0.5.6 is out and should propagate to the mirrors over the next two-three hours. It swaps the backing map to ConcurrentHashMap instead of Kotlin's MutableMap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants