gnodet-bot commented on code in PR #26762:
URL: https://github.com/apache/camel/pull/26762#discussion_r4082072248
##########
components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java:
##########
@@ -96,6 +97,7 @@ public abstract class GenericFileEndpoint<T> extends
ScheduledPollEndpoint imple
+ "file exists. This option configures what file
name to use. Either you can specify a fixed name. Or you "
+ "can use dynamic placeholders.The done file is
always expected in the same folder as the original "
+ "file.<p/> Only ${file.name} and
${file.name.next} is supported as dynamic placeholders.")
+ @Metadata(supportSimpleExpression = true)
protected String doneFileName;
Review Comment:
⚠️ **Side effect: `deprecationNote: ""` written to generated JSON**
Adding `@Metadata(supportSimpleExpression = true)` here makes the annotation
processor pick up `deprecationNote()` (whose default is `""`). `JsonMapper`
line 943 writes `deprecationNote` unconditionally, so every downstream JSON now
gets `"deprecationNote": ""` on `doneFileName` — a field that communicates
deprecation info — even though this option is not deprecated.
Before this PR the field had no `@Metadata` at all, so `deprecationNote` was
`null` and was serialized as `null` (invisible in the JSON). Now it's `""`.
Fix on the generator side:
```suggestion
@Metadata(supportSimpleExpression = true)
```
No change to the annotation itself — the fix belongs in
`EndpointSchemaGeneratorMojo` where `deprecationNote` is set: guard the
assignment with `if (!Strings.isNullOrEmpty(deprecationNote))` before calling
`option.setDeprecationNote(deprecationNote)` (around line 968 in the mojo).
That way an empty default never propagates.
##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/YamlValidator.java:
##########
@@ -754,11 +757,27 @@ private static String expressionInPath(String uri) {
}
/**
- * Components that evaluate their path for each message, where an
expression in it is what the component is for: the
- * language component's script, and the metric name of the two metrics
components. Each was read in the component's
- * own producer; CAMEL-24918 replaces this list with metadata in the
catalog, so that a component says it itself.
+ * The one component whose path is a script written in another language,
so what is in it is not the catalog's to
+ * say: language:simple:Hello ${body} is the script, not an address.
Everything else is read from the catalog
+ * (CAMEL-24918).
*/
- private static final Set<String> EVALUATED_PATH = Set.of("language",
"micrometer", "opentelemetry-metrics");
+ private static final Set<String> SCRIPT_PATH = Set.of("language");
+
+ /**
+ * Whether the component evaluates its path for each message, which its
catalog metadata says: an expression is then
+ * what the path is for, as in micrometer:counter:orders.${header.region}
(CAMEL-24918).
+ */
+ private boolean pathTakesAnExpression(String component) {
+ try {
+ ComponentModel model = catalog().componentModel(component);
+ if (model == null) {
+ return true; // a component the catalog does not know: say
nothing rather than the wrong thing
+ }
+ return
model.getEndpointPathOptions().stream().anyMatch(BaseOptionModel::isSupportSimpleExpression);
+ } catch (Exception e) {
+ return true;
+ }
Review Comment:
💡 **Fail-open silences catalog errors**
`catch (Exception e) { return true; }` means any exception (NPE, IO,
classloading) makes the validator treat the component as if its path is
expression-evaluated — suppressing the hint rather than reporting neutrally. In
practice the catalog is always on the classpath, so this never fires, but a log
line would make future failures diagnosable.
```suggestion
} catch (Exception e) {
log.debug("Could not load catalog model for component '{}',
skipping path expression check", component, e);
return true;
```
(Assuming a `log` field exists on `YamlValidator`; adjust to whatever logger
the class uses.)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]