maytasm opened a new pull request, #16612:
URL: https://github.com/apache/druid/pull/16612

   Fix task context fails with non string property value
   
   ### Description
   
   This is a regression caused by https://github.com/apache/druid/pull/14239
   The above PR introduces a new method `addSystemProperty` with String type in 
the method definition for the property value. (Previously, we were using 
`StringUtils.format` which takes in Object as argument). The problem is that 
`task.getContextValue(propName)` has a return type which is a generic type 
parameter ContextValueType. This means the method can return a value of any 
type specified at the time of invocation. When the value of the context 
property is not a String, Java is still trying to call the `addSystemProperty` 
with String type causing the task to fail. 
   i.e. if we have something like
   ```
     "context": {
       "druid.indexer.fork.property.druid.processing.numThreads": 4
     }
   ```
   we'll get the error: 
   ```
   java.lang.ClassCastException: java.lang.Integer cannot be cast to 
java.lang.String
        at 
org.apache.druid.indexing.overlord.ForkingTaskRunner$1.call(ForkingTaskRunner.java:319)
 [druid-indexing-service-31.0.0-SNAPSHOT.jar:31.0.0-SNAPSHOT]
        at 
org.apache.druid.indexing.overlord.ForkingTaskRunner$1.call(ForkingTaskRunner.java:171)
 [druid-indexing-service-31.0.0-SNAPSHOT.jar:31.0.0-SNAPSHOT]
        at 
com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
 [guava-32.0.1-jre.jar:?]
        at 
com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:75)
 [guava-32.0.1-jre.jar:?]
        at 
com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
 [guava-32.0.1-jre.jar:?]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:1.8.0_322]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:1.8.0_322]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_322]
   ```
   
   This PR fix the issue by casting the return value from 
`task.getContextValue(propName)` to Object and then use `addSystemProperty` 
with Object type for the value parameter.
   
   This PR has:
   
   - [x] been self-reviewed.
      - [ ] using the [concurrency 
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
 (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [x] been tested in a test Druid cluster.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to