You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Croway (via GitHub)" <gi...@apache.org> on 2026/09/09 10:16:34 UTC
[PR] [backport camel-spring-boot-4.22.x] CAMEL-24504: camel-spring-boot - extend the String conversion guard beyond InputStream [camel-spring-boot]
Croway opened a new pull request, #1957:
URL: https://github.com/apache/camel-spring-boot/pull/1957
Cherry-pick of #1912 onto `camel-spring-boot-4.22.x`.
**Original PR:** #1912 — camel-spring-boot - extend the String conversion guard beyond InputStream
**JIRA:** [CAMEL-24504](https://issues.apache.org/jira/browse/CAMEL-24504)
### What it fixes
CAMEL-23378 previously stopped `SpringTypeConverter` from converting a `String` into an `InputStream`
(or a subclass such as `FileInputStream`), because Spring's `ObjectToObjectConverter` locates the
`FileInputStream(String)` constructor and opens the value as a file path rather than treating it as
in-memory data content.
The same reasoning applies to any other target type whose single-`String` constructor interprets the
string as a path rather than as content. `FileReader` and `ZipFile` currently throw a
`ConversionFailedException` when Spring is asked to convert a `String` body, which prevents Camel's own
(correct) converters from ever getting a chance to run. `FileWriter` is worse: the conversion succeeds
and silently creates the named file on disk.
This change extends the existing guard to also cover `Reader`, `Writer`, and `ZipFile` targets, so Spring
returns `null` for those and Camel's own type converters handle the `String` body instead. `java.io.File`
is deliberately left out of the guard: `String -> File` is a documented, intentional Spring conversion
where the string genuinely represents a path (this is exactly what CAMEL-23378 was designed to preserve).
### Not a behavior change for correct usage
This only closes an implicit/unintended conversion path where a `String` message body could be silently
treated as a filesystem path by Spring's generic object conversion machinery — e.g. `Writer`/`Reader`/`ZipFile`
targets built from `File*`/`ZipFile` constructors that take a path. It does not remove any documented
Spring or Camel conversion capability; `StringReader` (and other in-memory-backed conversions) continue to
work as before, and `String -> File` is intentionally untouched.
### Verification on this branch
- Cherry-pick applied with no conflicts — both the main source file
(`SpringTypeConverter.java`) and the test file
(`SpringTypeConverterTest.java`, which already uses the same
`org.apache.camel.test.spring.junit6.CamelSpringBootTest` import as `main` on this branch) applied
cleanly.
- Ran the full `core/camel-spring-boot` module test suite (`./mvnw verify`, after temporarily repointing
the SNAPSHOT parent/`camel-version` and the `org.apache.camel` core dependency entries in
`tooling/camel-spring-boot-dependencies/pom.xml` to the released 4.22.0 for local resolvability, then
reverting all of that before pushing): 143 tests run (including the `CamelVirtualThreadsIT` failsafe
integration test), 0 failures, 0 errors, 1 skipped (pre-existing, unrelated). The specific
`SpringTypeConverterTest` class ran 8 tests (3 pre-existing + 5 new from this change), all passing.
- Module build (`./mvnw -DskipTests -Dfastinstall install -pl core/camel-spring-boot -am`): BUILD SUCCESS.
_Claude Code on behalf of Federico Mariani_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [backport camel-spring-boot-4.22.x] CAMEL-24504: camel-spring-boot - extend the String conversion guard beyond InputStream [camel-spring-boot]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway merged PR #1957:
URL: https://github.com/apache/camel-spring-boot/pull/1957
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org