-
Notifications
You must be signed in to change notification settings - Fork 479
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
InfluxDBResultMapper not thread safe? #430
Comments
:-O I'll fix the I'm sure we may see even performance improvements by checking first if the member is accessible or not, before setting it to true. Currently we are wasting time here because Currently I'm returning the 'accessible' flag to the previous state but I don't think there is any benefit from doing it so I'll remove this approach. Thanks @Schntzlbrmpf ! |
Hi Fernando, The way I see it, it might be the best solution to:
The main problem with using the field directly is that it must be public if we want a fast mapping. If we could make the mapper call the (public) accessor methods instead, we might get a considerable performance increase and at the same time keep a clean interface even to our POJOs. Best regards and thank you, |
@Schntzlbrmpf The current implementation is making changes (by setting the accessible flag to true) that were supposed to be permanent so, there is no reason to revert it. I did this initially because (1) I could not identify any collateral affect and (2) it's more simple and performant than both solutions that you proposed (remember: I'm doing not per instance but at class level). Take a look at the PR that I've just added here. Am I missing something? |
Hello Fernando, Sorry for this unbelievably late response. I think this is an acceptable solution. Thank you for your quick fix. Best regards ... |
I am refering to this part of the documentation:
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); // thread-safe - can be reused
List cpuList = resultMapper.toPOJO(queryResult, Cpu.class);
The problem is when I perform a multi-threaded mapping similar to this part of the code in several threads in parallel:
List cpuList = resultMapper.toPOJO(queryResult, Cpu.class);
I do get the following exception:
org.influxdb.InfluxDBMapperException: java.lang.IllegalAccessException: Class org.influxdb.impl.InfluxDBResultMapper can not access a member of class org.influx.test.Cpu with modifiers "private"
at org.influxdb.impl.InfluxDBResultMapper.parseSeriesAs(InfluxDBResultMapper.java:184)
at org.influxdb.impl.InfluxDBResultMapper.lambda$null$2(InfluxDBResultMapper.java:100)
The problem is most likely that the first thread did already set the accessibility of a field back to its original value when the second thread tries to write the field.
The text was updated successfully, but these errors were encountered: