gnodet opened a new pull request, #31201:
URL: https://github.com/apache/camel/pull/31201

   Fixes https://issues.apache.org/jira/browse/CAMEL-27910
   
   This PR addresses three distinct bugs found in `camel-kubernetes`:
   
   ## Bug 1: NPE on missing operation in `KubernetesJobProducer` and 
`KubernetesCronJobProducer`
   
   When no `operation` is set on the endpoint (or the 
`KubernetesOperationsEnum` header is missing), the producer calls `switch 
(operation)` on a `null` value, throwing an unguided `NullPointerException`. 
The fix replaces the bare `switch` with an explicit null-check that throws 
`IllegalArgumentException` with a diagnostic message.
   
   ## Bug 2: `KubernetesClusterService` ignores `namespace`, `masterUrl`, 
`connectionTimeout` when no config is passed
   
   When `KubernetesClusterService` is constructed with the no-arg constructor 
(`configuration == null`), `doInit()` creates a fresh `KubernetesConfiguration` 
but then overwrites `this.configuration` with it **after** the null check — the 
three setters that follow the null check use the local variable correctly, but 
the old code left the assignment in the wrong branch. The result: `namespace`, 
`masterUrl` and `connectionTimeout` set via their own setters were silently 
discarded.
   
   The fix restructures `doInit()` so both paths (null and non-null) always 
propagate those fields into the resulting configuration, and adds a 
package-private `getConfiguration()` accessor for tests.
   
   ## Bug 3: `KubernetesCustomResourcesConsumer` retries forever when no 
namespace is set
   
   When no namespace is configured the consumer task logged `"namespace is not 
specified"` and then called `inNamespace(null)`, which either throws in fabric8 
or silently scoped to the wrong namespace and kept retrying. The fix throws 
`IllegalArgumentException` immediately so the route fails fast with a clear 
diagnostic.
   
   ## Tests
   
   | Test class | New test |
   |---|---|
   | `KubernetesJobProducerTest` | 
`missingOperationThrowsIllegalArgumentException` |
   | `KubernetesCronJobProducerTest` | 
`missingOperationThrowsIllegalArgumentException` |
   | `KubernetesClusterServiceInitTest` _(new)_ | 
`namespaceAppliedWhenNoExplicitConfiguration`, 
`namespaceAppliedWhenExplicitConfiguration` |
   | `KubernetesCustomResourcesConsumerMissingNamespaceTest` _(new)_ | 
`missingNamespaceThrowsIllegalArgumentException` |
   
   All 19 tests pass locally.


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