You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/12/06 17:07:46 UTC
[camel] 07/10: (chores) camel-facebook: replace inner class with lambda
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit db8a71849dab93632a5d6da83346006e71f94dd5
Author: Gilvan Filho <gi...@gmail.com>
AuthorDate: Mon Dec 5 20:34:00 2022 -0300
(chores) camel-facebook: replace inner class with lambda
---
.../camel/component/facebook/FacebookProducer.java | 63 +++++++++++-----------
1 file changed, 30 insertions(+), 33 deletions(-)
diff --git a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java
index e70f92ad400..7b188eef37a 100644
--- a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java
+++ b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookProducer.java
@@ -79,44 +79,41 @@ public class FacebookProducer extends DefaultAsyncProducer {
// create a runnable invocation task to be submitted on a background thread pool
// this way we avoid blocking the current thread for long running operations
- Runnable invocation = new Runnable() {
- @Override
- public void run() {
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Invoking method {} with {}", method.getName(), properties.keySet());
- }
+ Runnable invocation = () -> {
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Invoking method {} with {}", method.getName(), properties.keySet());
+ }
- // also check whether we need to get Raw JSON
- Object result;
- String rawJSON = null;
- if (endpoint.getConfiguration().getJsonStoreEnabled() == null
- || !endpoint.getConfiguration().getJsonStoreEnabled()) {
+ // also check whether we need to get Raw JSON
+ Object result;
+ String rawJSON = null;
+ if (endpoint.getConfiguration().getJsonStoreEnabled() == null
+ || !endpoint.getConfiguration().getJsonStoreEnabled()) {
+ result = FacebookMethodsTypeHelper.invokeMethod(
+ endpoint.getConfiguration().getFacebook(), method, properties);
+ } else {
+ final Facebook facebook = endpoint.getConfiguration().getFacebook();
+ // lock out the underlying Facebook object from other threads
+ synchronized (facebook) {
result = FacebookMethodsTypeHelper.invokeMethod(
- endpoint.getConfiguration().getFacebook(), method, properties);
- } else {
- final Facebook facebook = endpoint.getConfiguration().getFacebook();
- // lock out the underlying Facebook object from other threads
- synchronized (facebook) {
- result = FacebookMethodsTypeHelper.invokeMethod(
- facebook, method, properties);
- rawJSON = DataObjectFactory.getRawJSON(result);
- }
- }
-
- // producer returns a single response, even for methods with List return types
- exchange.getMessage().setBody(result);
- // copy headers
- exchange.getMessage().setHeaders(exchange.getIn().getHeaders());
- if (rawJSON != null) {
- exchange.getMessage().setHeader(FacebookConstants.RAW_JSON_HEADER, rawJSON);
+ facebook, method, properties);
+ rawJSON = DataObjectFactory.getRawJSON(result);
}
+ }
- } catch (Exception t) {
- exchange.setException(RuntimeCamelException.wrapRuntimeCamelException(t));
- } finally {
- callback.done(false);
+ // producer returns a single response, even for methods with List return types
+ exchange.getMessage().setBody(result);
+ // copy headers
+ exchange.getMessage().setHeaders(exchange.getIn().getHeaders());
+ if (rawJSON != null) {
+ exchange.getMessage().setHeader(FacebookConstants.RAW_JSON_HEADER, rawJSON);
}
+
+ } catch (Exception t) {
+ exchange.setException(RuntimeCamelException.wrapRuntimeCamelException(t));
+ } finally {
+ callback.done(false);
}
};