This is an automated email from the ASF dual-hosted git repository.

squakez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 25b4632db fix(source): use valid quotes when rewriting Java fromF URIs
25b4632db is described below

commit 25b4632db6b16f866d69e2ae15f6613b9426bf81
Author: Sanjeev Kumar <[email protected]>
AuthorDate: Wed Dec 2 20:49:30 2026 +0530

    fix(source): use valid quotes when rewriting Java fromF URIs
---
 pkg/util/source/inspector_java_source.go      |  2 +-
 pkg/util/source/inspector_java_source_test.go | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/pkg/util/source/inspector_java_source.go 
b/pkg/util/source/inspector_java_source.go
index cb3907a0b..41300641b 100644
--- a/pkg/util/source/inspector_java_source.go
+++ b/pkg/util/source/inspector_java_source.go
@@ -67,7 +67,7 @@ func replaceFromURIDoubleQuotesOnly(source *v1.SourceSpec, 
newFromURI string) (b
        originalContent := source.Content
 
        source.Content = 
replaceURIDoubleQuotedFrom.ReplaceAllString(source.Content, 
fmt.Sprintf(`from("%s")`, newFromURI))
-       source.Content = 
replaceURIDoubleQuotedFromF.ReplaceAllString(source.Content, 
fmt.Sprintf(`fromF('%s')`, newFromURI))
+       source.Content = 
replaceURIDoubleQuotedFromF.ReplaceAllString(source.Content, 
fmt.Sprintf(`fromF("%s")`, newFromURI))
 
        return originalContent != source.Content, nil
 }
diff --git a/pkg/util/source/inspector_java_source_test.go 
b/pkg/util/source/inspector_java_source_test.go
index 8440483b2..4e607b989 100644
--- a/pkg/util/source/inspector_java_source_test.go
+++ b/pkg/util/source/inspector_java_source_test.go
@@ -202,6 +202,26 @@ func TestJavaReplaceURI(t *testing.T) {
        assert.Equal(t, "from(\"direct:newURI?hello=world\").to(\"log:info\")", 
sourceSpec.Content)
 }
 
+func TestJavaReplaceFromFURI(t *testing.T) {
+       inspector := newTestJavaSourceInspector(t)
+
+       sourceSpec := &v1.SourceSpec{
+               DataSpec: v1.DataSpec{
+                       Name:    "test.java",
+                       Content: 
`fromF("timer:tick?period=60000").to("log:info")`,
+               },
+       }
+
+       replaced, err := inspector.ReplaceFromURI(
+               sourceSpec,
+               "direct:newURI?hello=world",
+       )
+
+       assert.Nil(t, err)
+       assert.True(t, replaced)
+       assert.Equal(t, `fromF("direct:newURI?hello=world").to("log:info")`, 
sourceSpec.Content)
+}
+
 func TestJavaReplaceMultiURI(t *testing.T) {
        inspector := newTestJavaSourceInspector(t)
 

Reply via email to