Commit d66b260
committed
Fix NoMethodError when encoding with invalid: :replace option
When encoding a string with `invalid: :replace` and `replace:` options but
without `undef: :replace`, JRuby was incorrectly throwing NoMethodError
instead of Encoding::UndefinedConversionError.
The bug occurred because when `ecopts` hash exists (due to `:replace` option)
but doesn't contain a `:fallback` key, the code was setting `fallbackFunc` to
`AREF_FALLBACK` with a nil `fallback` value. When an undefined conversion was
encountered, it tried to call `nil.[]()` which raised NoMethodError.
The fix adds a check for `!fallback.isNil()` before assigning the fallback
function, ensuring that the fallback is only used when explicitly provided.
Fixes #90091 parent 435d102 commit d66b260
File tree
2 files changed
+31
-8
lines changed- core/src/main/java/org/jruby/util/io
- test/jruby
2 files changed
+31
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1515 | 1515 | | |
1516 | 1516 | | |
1517 | 1517 | | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
1526 | 1528 | | |
1527 | 1529 | | |
1528 | 1530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
277 | 298 | | |
0 commit comments