This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c6d9876405c3 Use constant for charset instead of string literal in
HuggingFace component
c6d9876405c3 is described below
commit c6d9876405c39cbd7e99220aa27565eb1623ca60
Author: Aurélien Pupier <[email protected]>
AuthorDate: Fri Feb 27 14:38:49 2026 +0100
Use constant for charset instead of string literal in HuggingFace
component
reported by
https://sonarcloud.io/project/issues?open=AZx56ULBH2LkZt7aOY9E&id=apache_camel
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../huggingface/tasks/AutomaticSpeechRecognitionPredictor.java | 4 +++-
.../component/huggingface/tasks/ZeroShotClassificationPredictor.java | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git
a/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/AutomaticSpeechRecognitionPredictor.java
b/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/AutomaticSpeechRecognitionPredictor.java
index c085c7c29ae9..b6d2b8316eb8 100644
---
a/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/AutomaticSpeechRecognitionPredictor.java
+++
b/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/AutomaticSpeechRecognitionPredictor.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.huggingface.tasks;
+import java.nio.charset.StandardCharsets;
+
import ai.djl.modality.Input;
import ai.djl.modality.Output;
import ai.djl.modality.audio.Audio;
@@ -126,7 +128,7 @@ public class AutomaticSpeechRecognitionPredictor extends
AbstractTaskPredictor {
String waveformJson = objectMapper.writeValueAsString(waveform);
Input input = new Input();
- input.add("data", waveformJson.getBytes("UTF-8"));
+ input.add("data", waveformJson.getBytes(StandardCharsets.UTF_8));
return input;
}
diff --git
a/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/ZeroShotClassificationPredictor.java
b/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/ZeroShotClassificationPredictor.java
index b61dca2707b3..cf3dadadac29 100644
---
a/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/ZeroShotClassificationPredictor.java
+++
b/components/camel-ai/camel-huggingface/src/main/java/org/apache/camel/component/huggingface/tasks/ZeroShotClassificationPredictor.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.huggingface.tasks;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -118,7 +119,7 @@ public class ZeroShotClassificationPredictor extends
AbstractTaskPredictor {
}
String jsonArray = objectMapper.writeValueAsString(inputArray);
Input input = new Input();
- input.add("data", jsonArray.getBytes("UTF-8"));
+ input.add("data", jsonArray.getBytes(StandardCharsets.UTF_8));
return input;
}