From eca784de0079b4dc6116baf32a994d9a4a832083 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 20 Mar 2019 17:57:25 -0400 Subject: [PATCH] Fixes accoridng upgrades --- .../twitter/inbound/AbstractTwitterMessageSource.java | 6 +++--- .../outbound/DirectMessageSendingMessageHandler.java | 7 ++++--- .../twitter/outbound/StatusUpdatingMessageHandler.java | 6 +++--- .../twitter/outbound/TwitterSearchOutboundGateway.java | 8 +++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/inbound/AbstractTwitterMessageSource.java b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/inbound/AbstractTwitterMessageSource.java index 13463a8..2346733 100644 --- a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/inbound/AbstractTwitterMessageSource.java +++ b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/inbound/AbstractTwitterMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ abstract class AbstractTwitterMessageSource extends IntegrationObjectSupport private final String metadataKey; - private final Queue tweets = new LinkedBlockingQueue(); + private final Queue tweets = new LinkedBlockingQueue<>(); private volatile MetadataStore metadataStore; @@ -120,7 +120,7 @@ abstract class AbstractTwitterMessageSource extends IntegrationObjectSupport } @Override - protected void onInit() throws Exception { + protected void onInit() { super.onInit(); if (this.metadataStore == null) { // first try to look for a 'metadataStore' in the context diff --git a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/DirectMessageSendingMessageHandler.java b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/DirectMessageSendingMessageHandler.java index 7d1ef36..2842574 100644 --- a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/DirectMessageSendingMessageHandler.java +++ b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/DirectMessageSendingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.util.Assert; * @author Josh Long * @author Oleg Zhurakousky * @author Mark Fisher + * @author Artem Bilan */ public class DirectMessageSendingMessageHandler extends AbstractMessageHandler { @@ -45,7 +46,7 @@ public class DirectMessageSendingMessageHandler extends AbstractMessageHandler { } @Override - protected void handleMessageInternal(Message message) throws Exception { + protected void handleMessageInternal(Message message) { Assert.isTrue(message.getPayload() instanceof String, "Only payload of type String is supported. " + "Consider adding a transformer to the message flow in front of this adapter."); Object toUser = message.getHeaders().get(TwitterHeaders.DM_TARGET_USER_ID); @@ -56,7 +57,7 @@ public class DirectMessageSendingMessageHandler extends AbstractMessageHandler { if (toUser instanceof Number) { this.twitter.directMessageOperations().sendDirectMessage(((Number) toUser).longValue(), payload); } - else if (toUser instanceof String) { + else { this.twitter.directMessageOperations().sendDirectMessage((String) toUser, payload); } } diff --git a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java index 1ad4e64..7c4f35f 100644 --- a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java +++ b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class StatusUpdatingMessageHandler extends AbstractMessageHandler { } @Override - protected void onInit() throws Exception { + protected void onInit() { super.onInit(); if (this.evaluationContext == null) { @@ -89,7 +89,7 @@ public class StatusUpdatingMessageHandler extends AbstractMessageHandler { } @Override - protected void handleMessageInternal(Message message) throws Exception { + protected void handleMessageInternal(Message message) { Object value; if (this.tweetDataExpression != null) { value = this.tweetDataExpression.getValue(this.evaluationContext, message); diff --git a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGateway.java b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGateway.java index fea601c..1ee729e 100644 --- a/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGateway.java +++ b/spring-integration-social-twitter/src/main/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGateway.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import org.springframework.util.Assert; * expression evaluation. * * @author Gary Russell + * @author Artem Bilan */ public class TwitterSearchOutboundGateway extends AbstractReplyProducingMessageHandler { @@ -147,8 +148,9 @@ public class TwitterSearchOutboundGateway extends AbstractReplyProducingMessageH } SearchResults results = this.getTwitter().searchOperations().search(searchParameters); if (results != null) { - List tweets = (results.getTweets() != null ? results.getTweets() : Collections.emptyList()); - return this.getMessageBuilderFactory().withPayload(tweets) + List tweets = results.getTweets() != null ? results.getTweets() : Collections.emptyList(); + return getMessageBuilderFactory() + .withPayload(tweets) .setHeader(TwitterHeaders.SEARCH_METADATA, results.getSearchMetadata()); } else {