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

   ## Problem
   
   Six header `javaType` values name dockerjava model classes by simple name 
only, and two of them name the *wrong* class.
   
   `DockerHelper.getArrayProperty` accepts either one element or an array of 
that element type:
   
   ```java
   public static <T> T[] getArrayProperty(String name, Message message, 
Class<T> clazz) {
       ...
       if (header.getClass().isAssignableFrom(clazz)) {      // a single element
       ...
       if (header.getClass().isArray()) {                    // or an array of 
them
   ```
   
   so `X or X[]` is the right shape for those headers - as long as `X` is the 
element class.
   
   ### `CamelDockerExposedPorts` says `ExposedPorts[]`, which is never read
   
   ```java
   @Metadata(description = "The exposed ports", javaType = "ExposedPorts or 
ExposedPorts[]")
   public static final String DOCKER_EXPOSED_PORTS = "CamelDockerExposedPorts";
   ```
   
   The producer reads it two ways, and neither is an `ExposedPorts[]`:
   
   ```java
   = DockerHelper.getProperty(DockerConstants.DOCKER_EXPOSED_PORTS, 
configuration, message, ExposedPorts.class);
   ...
   = DockerHelper.getArrayProperty(DockerConstants.DOCKER_EXPOSED_PORTS, 
message, ExposedPort.class);
   ```
   
   `ExposedPorts` and `ExposedPort` are two different classes in 
`com.github.dockerjava.api.model` - the second is the element, and the array 
form is `ExposedPort[]`.
   
   ### `CamelDockerVolumes` says `Volume`, but the object form read is `Volumes`
   
   ```java
   @Metadata(description = "With volumes", javaType = "Volume or Volume[]")
   public static final String DOCKER_VOLUMES = "CamelDockerVolumes";
   ```
   
   ```java
   Volumes volumes = DockerHelper.getProperty(DockerConstants.DOCKER_VOLUMES, 
configuration, message, Volumes.class);
   ...
   Volume[] volume = 
DockerHelper.getArrayProperty(DockerConstants.DOCKER_VOLUMES, message, 
Volume.class);
   ```
   
   So the single-object form the catalog advertises - a bare `Volume` - is not 
what that path reads; it reads the `Volumes` wrapper, which the catalog does 
not mention at all.
   
   ### The remaining four are correct but unqualified
   
   `Bind`, `VolumesFrom` and `Capability` (twice) are all 
`com.github.dockerjava.api.model`. Fully qualified is the convention by a wide 
margin across the catalog: 3692 header `javaType` values are fully qualified or 
a built-in type, and 151 are not.
   
   ## Fix
   
   Qualify all six, and correct the two that named the wrong class, listing 
each form the producer actually reads:
   
   ```
   CamelDockerExposedPorts : ...ExposedPorts or ...ExposedPort or 
...ExposedPort[]
   CamelDockerVolumes      : ...Volumes or ...Volume or ...Volume[]
   ```
   
   Metadata only - no behaviour change, and no header name touched. I diffed 
the regenerated catalog file against `main` and confirmed the six `javaType` 
values are the only fields that differ.
   


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