Dhairya-007 opened a new pull request, #29418:
URL: https://github.com/apache/camel/pull/29418

   Six URI options of type `enum` document a `defaultValue` that is not one of 
the values the same option declares.
   
   | component | option | documented default | declared enum values |
   |---|---|---|---|
   | azure-eventhubs | `amqpTransportType` | `AMQP` | `Amqp`, `AmqpWebSockets` |
   | azure-servicebus | `amqpTransportType` | `AMQP` | `Amqp`, `AmqpWebSockets` 
|
   | azure-cosmosdb | `consistencyLevel` | `SESSION` | `Strong`, 
`BoundedStaleness`, `Session`, `Eventual`, `ConsistentPrefix` |
   | azure-storage-blob | `blockListType` | `COMMITTED` | `committed`, 
`uncommitted`, `all` |
   | platform-http | `cookieSameSite` | `Lax` | `STRICT`, `LAX`, `NONE` |
   | hazelcast-queue | `queueConsumerMode` | `Listen` | `listen`, `poll` |
   
   ### How they drifted apart
   
   `EndpointSchemaGeneratorMojo.getEnums` builds the `enum` list from 
`toString()` of each enum constant:
   
   ```java
   for (Object val : fieldType.getEnumConstants()) {
       String str = val.toString();
   ```
   
   The four Azure types and `HazelcastQueueConsumerMode` all override 
`toString()` to return a display string rather than the constant name, so the 
generated list uses that spelling while the hand-written `defaultValue` in the 
annotation uses the constant name — or, for `cookieSameSite`, a third spelling 
that is neither (`CookieSameSite` has no custom `toString()`, and the field is 
initialised to `CookieSameSite.LAX`).
   
   The result is a catalog entry that reads, for example, `"enum": [ "listen", 
"poll" ], "defaultValue": "Listen"`, so tooling that renders the default next 
to the list of permitted values shows a value that is not in the list, and 
`AbstractCamelCatalog.asEndpointUri` — which drops an option whose value 
matches the default with an exact `equals` — drops the spelling that is not the 
documented one.
   
   ### Scope
   
   Only the `defaultValue` strings change; no field initializer is touched, so 
there is no behaviour change. `EnumTypeConverter` matches on `name()` 
case-insensitively and also via `StringHelper.asEnumConstantValue`, and 
`AbstractCamelCatalog.isEnumValue` is case-insensitive too, so both the old and 
the new spelling of each of these six values resolve and validate exactly as 
before — this is a metadata-consistency fix, not a functional one.
   
   I found these by walking the generated catalog for options where `type` is 
`enum` and `defaultValue` is not a member of `enum`. After the change only one 
case is left in the whole catalog:
   
   ```
   models/avro.json | library | default='avroJackson' | enum=['ApacheAvro', 
'Jackson']
   ```
   
   That one is **not** in this PR. `avroJackson` is genuinely rejected by 
`isEnumValue`, but it is also the default string baked into the generated model 
writers (`ModelWriter`, `YamlModelWriter`, `JavaDslModelWriter`), which skip an 
attribute when `toString(def.getLibrary())` equals it. Changing it there would 
make the writers start emitting `library="avroJackson"`, which readers cannot 
parse back, so it needs a decision about whether the writers should use 
`name()` instead of `toString()` for enum attributes. Happy to follow up on it 
separately if you want it fixed.
   
   ### Generated files
   
   Regenerated by hand, since building these modules locally means building 
most of Camel at the current SNAPSHOT: each component's 
`src/generated/resources/META-INF/.../<scheme>.json` and the `camel-catalog` 
copy, which I verified stay byte-identical to each other after the edit. The 
`docs/components/modules/ROOT/examples/json` entries are symlinks to the 
component copies, so they follow automatically.
   


-- 
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]

Reply via email to