Skip to content

camel-diagram: Fix route source name stripping line numbers#22991

Open
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:diagram-fix-source-name
Open

camel-diagram: Fix route source name stripping line numbers#22991
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:diagram-fix-source-name

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 6, 2026

Fix route source display in diagram that was stripping line numbers from source names like cheese.java:9, showing just 9 instead.

Problem

extractSourceName() used lastIndexOf(':') to strip URI scheme prefixes (e.g. file:), but this also stripped line number suffixes from sources like cheese.java:9, leaving just 9.

Fix

Changed to use indexOf(':') (first colon) with a check that the part before the colon consists only of letters (a valid URI scheme like file, classpath, ref). This correctly handles:

  • file:/path/to/my-route.yamlmy-route.yaml
  • classpath:my-route.yamlmy-route.yaml
  • cheese.java:9cheese.java:9 (preserved)
  • file:/path/to/cheese.java:9cheese.java:9 (preserved)

Test plan

  • Added unit tests for all source name extraction scenarios
  • All 58 tests pass in camel-diagram module

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🧪 CI tested the following changed modules:

  • components/camel-diagram
All tested modules (9 modules)
  • Camel :: Diagram
  • Camel :: JBang :: Console
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet marked this pull request as ready for review May 6, 2026 08:47
@gnodet gnodet requested review from davsclaus and oscerd May 6, 2026 08:47
@davsclaus
Copy link
Copy Markdown
Contributor

this is no longer needed as the json source from route structure dump has removed the line number and include this in a seperate "line" attribute

The extractSourceName() method used lastIndexOf(':') to strip URI scheme
prefixes, which also stripped line number suffixes from sources like
"cheese.java:9", leaving just "9". Changed to use indexOf(':') with a
check that the part before the colon is all letters (a valid URI scheme),
preserving line numbers in the display.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented May 6, 2026

Claude Code on behalf of Guillaume Nodet

True, but the code is still wrong regardless — it uses lastIndexOf(':') to strip the scheme prefix, which means it keeps only the part after the last colon rather than stripping the first part (the scheme). For example, classpath:my-route.yaml:10 would produce 10 instead of my-route.yaml:10.

The fix changes to indexOf(':') with a check that the part before the colon is all letters (a valid URI scheme), so it correctly strips only the scheme prefix.

@gnodet gnodet force-pushed the diagram-fix-source-name branch from bf1b171 to a933542 Compare May 6, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants