Commit 09d7e13
Fix nondeterministic constant ordering causing possible incorrect in-memory evaluation (#1803)
* Fix nondeterministic constant ordering causing incorrect in-memory evaluation
Problem:
`DefaultEvaluatorFactory` builds compiled evaluators with from a non-deterministic
ordering of constants. This can lead to mismatches between the cached generated
java method and the runtime argument order, producing incorrect evaluation results.
`AbstractEvaluatorFactory#toId` only includes constant types in the cache key,
not their values. This is safe only if argument ordering is stable, which is
not guaranteed with the current constant resolution logic.
For example, the predicate `QEntity.entity.prop1.eq(true).or(QEntity.entity.prop2.eq(false))`
may result in a mismatch where the same compiled method is reused, but
arguments are supplied in a different order. The method may be invoked with
`[true, false]` (correct) or `[false, true]` (incorrect), leading to inverted
semantics at evaluation time.
Solution:
This change ensures deterministic constant ordering so that compiled methods
and runtime arguments always remain aligned.
* Apply code formatting to DefaultEvaluatorFactory
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
* Add regression test for deterministic constant ordering
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
---------
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
Co-authored-by: Alexandre Potvin Latreille <alexandre.potvinlatreille@cra-arc.gc.ca>
Co-authored-by: Marvin Froeder <velo.br@gmail.com>1 parent 5584909 commit 09d7e13
2 files changed
Lines changed: 93 additions & 17 deletions
File tree
- querydsl-libraries/querydsl-collections/src
- main/java/com/querydsl/collections
- test/java/com/querydsl/collections
Lines changed: 21 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
| 115 | + | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
| 158 | + | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
| |||
269 | 268 | | |
270 | 269 | | |
271 | 270 | | |
272 | | - | |
273 | | - | |
| 271 | + | |
274 | 272 | | |
275 | 273 | | |
276 | 274 | | |
| |||
283 | 281 | | |
284 | 282 | | |
285 | 283 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
291 | 292 | | |
292 | | - | |
| 293 | + | |
293 | 294 | | |
294 | | - | |
295 | | - | |
296 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
297 | 298 | | |
| 299 | + | |
| 300 | + | |
298 | 301 | | |
299 | | - | |
| 302 | + | |
| 303 | + | |
300 | 304 | | |
301 | 305 | | |
Lines changed: 72 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
0 commit comments