Comments (12)
I don't yet know what's the reason, but at least I know how to reproduce it.
Just run this single test in IDEA, then open "Run Configurations" -> "Edit configurations" -> "Modify options" -> "Repeat" -> "Until failure". And run again.
Now test will be re-running endlessly, and sooner or later will fail with the expected error.
from datafaker.
I've done some debugging, and this is what I see:
![image](https://private-user-images.githubusercontent.com/46468/350692307-19b5399b-a7b6-4634-9378-34091433a9ec.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzMzE1NDcsIm5iZiI6MTcyMjMzMTI0NywicGF0aCI6Ii80NjQ2OC8zNTA2OTIzMDctMTliNTM5OWItYTdiNi00NjM0LTkzNzgtMzQwOTE0MzNhOWVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDA5MjA0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM3OTBjYTkyY2M1OTE3NjNkNDE3NGY4YjY2N2RhMDExMTI3ZDhiZjNkZWJmMTE4ZTY0MTQwMTNkMTM2YjdlNWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Ucz9D4udE7FtS-GfyonQ19mcmZ44rcJ45tZDZrRjFPA)
It's coming from here:
Map<String[], MethodAndCoercedArgs> accessorMap =
MAP_OF_METHOD_AND_COERCED_ARGS
.getOrDefault(clazz, Collections.emptyMap())
.getOrDefault(methodName, Collections.emptyMap());
// value could be null
if (accessorMap.containsKey(args)) { <--- accessorMap is sometimes null
return accessorMap.get(args);
}
I don't think the accessorMap
can be null
under normal circumstances, but this is the COWMap, I'm not sure if that's related, but not sure how accessorMap can be null here (sometimes). When it's null, the nullpointer is swallowed by the above code when it's catching Exception.
from datafaker.
I'm good with that 👆
Though I'm not exactly an authority for the project 😁
from datafaker.
@RVRhub I remember you also mentioned some findings about this
from datafaker.
@bodiam @snuyanzin I could reproduce the failure, but still don't understand why it happens.
What I suggest:
I can submit a PR that improves logging and adds debug logs at some places in DF.
Then we can get more information from debug logs when it happens again.
from datafaker.
I can submit a PR that improves logging and adds debug logs at some places in DF.
I don't mind that, but perhaps for narrowing down the problem here only? It's probably not something we need to merge right, the debugging can happen on a branch?
from datafaker.
@bodiam It depends on the logging itself. But generally I think it's a good idea to add the logging to main branch.
DEBUG logs are disabled by default, so it will not affect users. But when someone decides to investigate some specific problem, they can easily enable debug logs for the entire DF or some specific package.
from datafaker.
Yes, this is one of my findings too. And proper logging would help to find this issue sooner. ;)
But it doesn't seem to cause our initial problem. :(
from datafaker.
@asolntsev See screenshot. There is a log message exactly there: LOG.fine(e.getMessage())
. That prints the nullpointer when you enable logging.
But I think it's related to the initial problem, since the above exception happens when some method returns null. In this case, null is returned when we get the NPE. Why do we get the NPE? I have no idea yet.
from datafaker.
Why do we get the NPE?
As a rule, exceptions must be logged with stack trace:
Log.log(FINE, e.getMessage(), e);
Then we would know why it happens.
And I don't understand why this log is FINE, not ERROR or at least WARNING.
Anyway, I am working on it.
from datafaker.
@bodiam @snuyanzin After some investigation, I came to a conclusion that this is a bug in CopyOnWriteMap
, or at least its usage.
I reproduced this problem in a dedicated unit-tests here: #1310
P.S. This is how CopyOnWriteMap
is used in FakeValuesService
:
final Map<String, Map<String[], MethodAndCoercedArgs>> stringMapMap =
MAP_OF_METHOD_AND_COERCED_ARGS.computeIfAbsent(clazz, t -> new CopyOnWriteMap<>(WeakHashMap::new));
// Step 1: we PUT value to map, but...
stringMapMap.putIfAbsent(methodName, new CopyOnWriteMap<>(WeakHashMap::new));
// Step 2: `map.get` returns NULL!
stringMapMap.get(methodName).putIfAbsent(args, accessor); // here `stringMapMap.get(methodName)` is NULL
Assumably, null is returned after GC run.
from datafaker.
My recommendation:
- Fix issue #1310 - @snuyanzin Can you help with this?
- Merge #1311
from datafaker.
Related Issues (20)
- Breaking DateAndTime HOT 4
- Intermitted expressions failures during testing HOT 8
- Regexify method doesn't recognise "^" and "$" chars in datafaker before 2.2.0. HOT 7
- Remove public methods from `IdNumber` that are not intended to be directly called HOT 8
- How to specify country-specific setting, not language-specific? HOT 2
- Feature request: add support to generate a random PNG/SVG. HOT 1
- 2.3.0 Release HOT 13
- Password generation does not always contain a lowercase letter HOT 3
- Publishing docs works now HOT 1
- Memory leak in maps containing FakerContext as a key HOT 30
- Memory leak for seeded random use case HOT 3
- Create a dictionary of obscene words HOT 8
- java.lang.ClassCastException for finance.credit_card provider with Enum argument in Faker expression HOT 5
- Problems with module-info.java with version 2.3.0 HOT 33
- New Project to improving tests HOT 9
- Locale specific generation performance degradation HOT 1
- Fix publishing of snapshots HOT 4
- Code coverage report is broken HOT 4
- Add weighted selection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datafaker.