You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2021/03/11 12:50:00 UTC
[camel] branch master updated: CAMEL-16336 Make
CustomSlackHttpClient compatible with okhttp 3.x
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 91839bb CAMEL-16336 Make CustomSlackHttpClient compatible with okhttp 3.x
91839bb is described below
commit 91839bb2ee857730a207c5bae71d4d6fd7e7930b
Author: Anthony Defraine <ro...@kinae.eu>
AuthorDate: Thu Mar 11 09:37:41 2021 +0100
CAMEL-16336 Make CustomSlackHttpClient compatible with okhttp 3.x
---
components/camel-slack/pom.xml | 13 +++++++------
.../apache/camel/component/slack/CustomSlackHttpClient.java | 2 +-
.../org/apache/camel/component/slack/SlackConsumer.java | 2 +-
.../org/apache/camel/component/slack/SlackConsumerTest.java | 2 +-
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/components/camel-slack/pom.xml b/components/camel-slack/pom.xml
index 9a89f2b..d3dcd20 100644
--- a/components/camel-slack/pom.xml
+++ b/components/camel-slack/pom.xml
@@ -50,12 +50,6 @@
<groupId>com.slack.api</groupId>
<artifactId>slack-api-client</artifactId>
<version>${slack-api-model-version}</version>
- <exclusions>
- <exclusion>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
@@ -74,6 +68,13 @@
</exclusions>
</dependency>
+ <!-- forcing okhttp v3.x related to https://issues.apache.org/jira/browse/CAMEL-16336 -->
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>${squareup-okhttp-version}</version>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>org.apache.camel</groupId>
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/CustomSlackHttpClient.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/CustomSlackHttpClient.java
index 10c6718..4cb8da4 100644
--- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/CustomSlackHttpClient.java
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/CustomSlackHttpClient.java
@@ -39,7 +39,7 @@ public class CustomSlackHttpClient extends SlackHttpClient {
@Override
public Response postJsonBody(String url, Object obj) throws IOException {
- RequestBody body = RequestBody.create((String) obj, MEDIA_TYPE_APPLICATION_JSON);
+ RequestBody body = RequestBody.create(MEDIA_TYPE_APPLICATION_JSON, (String) obj);
Request request = new Request.Builder().url(url).post(body).build();
return okHttpClient.newCall(request).execute();
}
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java
index 8d97fc7..812425f 100644
--- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java
@@ -152,7 +152,7 @@ public class SlackConsumer extends ScheduledBatchPollingConsumer {
.filter(it -> it.getName().equals(channel))
.map(Conversation::getId)
.findFirst().orElseGet(() -> {
- if (ObjectHelper.isNotEmpty(response.getResponseMetadata().getNextCursor())) {
+ if (ObjectHelper.isEmpty(response.getResponseMetadata().getNextCursor())) {
throw new RuntimeCamelException(String.format("Channel %s not found", channel));
}
return getChannelId(channel, response.getResponseMetadata().getNextCursor());
diff --git a/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java b/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java
index 25e2d8e..201e9f0 100644
--- a/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java
+++ b/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java
@@ -68,7 +68,7 @@ public class SlackConsumerTest extends CamelTestSupport {
private void sendMessage(String message) throws IOException {
RequestBody requestBody
- = RequestBody.create(String.format("{ 'text': '%s'}", message), MediaType.parse("application/json"));
+ = RequestBody.create(MediaType.parse("application/json"), String.format("{ 'text': '%s'}", message));
Request request = new Request.Builder()
.url(hook)