[Bug] Calling a value is not thread safe (return another value)
See original GitHub issueI noticed that when calling values from different threads, it can returns values from other methods. The wrong method is invoked somehow. Bug reproduced on version 1.0.11 I tried 1.0.8 - 1.0.10 and all ok.
src/test/resources/config.properties
firstName=Pasha
lastName=Bairov
import org.aeonbits.owner.Config;
@Config.Sources({"file:src/test/resources/config.properties"})
public interface MyConfig extends Config {
@Key("firstName")
String firstName();
@Key("lastName")
String lastName();
}
public static void main(String[] args) {
MyConfig cfg = ConfigFactory.create(MyConfig.class);
new Thread(() -> {
for (int i = 0; i < 1000; i++) {
String name = cfg.firstName();
if (!name.equals("Pasha")) {
System.out.println("name " + name);
}
}
}).start();
new Thread(() -> {
for (int i = 0; i < 1000; i++) {
cfg.lastName();
}
}).start();
}
I executed it 1000 times and here it stdout:
name Bairov
name Bairov
name Bairov
name Bairov
name Bairov
I can provide any necessary information for debugging.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
[Bug] Calling a value is not thread safe (return another value)
I noticed that when calling values from different threads, it can returns values from other methods. The wrong method is invoked somehow ...
Read more >Is it thread safe to read a form controls value (but not change it ...
Question 2: I have a second thread that needs to update form control values so I Invoke/BeginInvoke to update those values. Well this...
Read more >How to make thread-safe calls to controls - Windows Forms .NET
Learn how to implement multithreading in your app by calling cross-thread controls in a thread-safe way. If you encounter the 'cross-thread ...
Read more >inout paremeter and thread safety | Apple Developer Forums
When I call this func from another thread, I get random crashes (BAD_ACCESS). I understand it is not safe to pass address in...
Read more >Writing reentrant and threadsafe code - IBM
A thread may read an error code corresponding to an error caused by another thread. In AIX®, each thread has its own errno...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Amerousful Glad it helped. Thank you for your valuable time in helping.
thank you for the unit test, really appreciated you took the time to produce a test case to reproduce the issue. I wrote a unit test inspired to your code. So this issue hopefully will not show up again.