Avoid throws Exception where possible - Phase II
Final phase III to follow. * Polishing * Polishing
This commit is contained in:
committed by
Artem Bilan
parent
3d87ac6463
commit
b138ab80f8
@@ -253,7 +253,7 @@ public class AmqpInboundGateway extends MessagingGatewaySupport {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onMessage(final Message message, final Channel channel) throws Exception {
|
||||
public void onMessage(final Message message, final Channel channel) {
|
||||
if (AmqpInboundGateway.this.retryTemplate == null) {
|
||||
try {
|
||||
org.springframework.messaging.Message<Object> converted = convert(message, channel);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.integration.json;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -36,7 +37,7 @@ import com.jayway.jsonpath.Predicate;
|
||||
*/
|
||||
public final class JsonPathUtils {
|
||||
|
||||
public static <T> T evaluate(Object json, String jsonPath, Predicate... predicates) throws Exception {
|
||||
public static <T> T evaluate(Object json, String jsonPath, Predicate... predicates) throws IOException {
|
||||
if (json instanceof String) {
|
||||
return JsonPath.read((String) json, jsonPath, predicates);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -35,10 +35,9 @@ public interface InboundMessageMapper<T> {
|
||||
* Convert a provided object to the {@link Message}.
|
||||
* @param object the object for message payload or some other conversion logic
|
||||
* @return the message as a result of mapping
|
||||
* @throws Exception the exception thrown by the underlying mapper implementation
|
||||
*/
|
||||
@Nullable
|
||||
default Message<?> toMessage(T object) throws Exception { // NOSONAR - TODO remove Exception in 5.2
|
||||
default Message<?> toMessage(T object) {
|
||||
return toMessage(object, null);
|
||||
}
|
||||
|
||||
@@ -48,10 +47,9 @@ public interface InboundMessageMapper<T> {
|
||||
* @param object the object for message payload or some other conversion logic
|
||||
* @param headers additional headers for building message. Can be null
|
||||
* @return the message as a result of mapping
|
||||
* @throws Exception the exception thrown by the underlying mapper implementation
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
Message<?> toMessage(T object, @Nullable Map<String, Object> headers) throws Exception; // NOSONAR
|
||||
Message<?> toMessage(T object, @Nullable Map<String, Object> headers);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ import org.springframework.messaging.Message;
|
||||
public interface OutboundMessageMapper<T> {
|
||||
|
||||
@Nullable
|
||||
T fromMessage(Message<?> message) throws Exception; // NOSONAR
|
||||
T fromMessage(Message<?> message);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -91,7 +91,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
File baseDir = new File(this.baseDirectory);
|
||||
baseDir.mkdirs();
|
||||
this.file = new File(baseDir, this.fileName);
|
||||
@@ -195,7 +195,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
flush();
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
public void destroy() {
|
||||
flush();
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
catch (@SuppressWarnings("unused") Exception e2) {
|
||||
// non fatal
|
||||
this.logger.warn("Failed to close InputStream for: " + this.file.getAbsolutePath());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -90,7 +90,7 @@ public class ExpressionEvaluatingRoutingSlipRouteStrategy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
if (this.evaluationContext == null) {
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -90,12 +90,12 @@ public class MessageGroupStoreReaper implements Runnable, DisposableBean, Initia
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
Assert.state(this.messageGroupStore != null, "A MessageGroupStore must be provided");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
public void destroy() {
|
||||
if (this.expireOnDestroy) {
|
||||
if (this.isRunning()) {
|
||||
logger.info("Expiring all messages from message group store: " + this.messageGroupStore);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -134,7 +134,7 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<?> toMessage(Object object, @Nullable Map<String, Object> headers) throws Exception {
|
||||
public Message<?> toMessage(Object object, @Nullable Map<String, Object> headers) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromMessage(Message<?> message) throws Exception {
|
||||
public Object fromMessage(Message<?> message) {
|
||||
return (message != null) ? message.getPayload() : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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,15 +69,15 @@ abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<?> doInParser(JsonInboundMessageMapper messageMapper, String jsonMessage,
|
||||
@Nullable Map<String, Object> headers) throws Exception {
|
||||
public Message<?> doInParser(JsonInboundMessageMapper messageMapperToUse, String jsonMessage,
|
||||
@Nullable Map<String, Object> headers) {
|
||||
|
||||
if (this.messageMapper == null) {
|
||||
this.messageMapper = messageMapper;
|
||||
this.messageMapper = messageMapperToUse;
|
||||
}
|
||||
P parser = this.createJsonParser(jsonMessage);
|
||||
|
||||
if (messageMapper.isMapToPayload()) {
|
||||
if (messageMapperToUse.isMapToPayload()) {
|
||||
Object payload = readPayload(parser, jsonMessage);
|
||||
return getMessageBuilderFactory()
|
||||
.withPayload(payload)
|
||||
@@ -89,7 +89,7 @@ abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessage
|
||||
}
|
||||
}
|
||||
|
||||
protected Object readPayload(P parser, String jsonMessage) throws Exception {
|
||||
protected Object readPayload(P parser, String jsonMessage) {
|
||||
try {
|
||||
return this.objectMapper.fromJson(parser, this.messageMapper.getPayloadType());
|
||||
}
|
||||
@@ -99,7 +99,7 @@ abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessage
|
||||
}
|
||||
}
|
||||
|
||||
protected Object readHeader(P parser, String headerName, String jsonMessage) throws Exception {
|
||||
protected Object readHeader(P parser, String headerName, String jsonMessage) {
|
||||
Class<?> headerType = this.messageMapper.getHeaderTypes().getOrDefault(headerName, Object.class);
|
||||
try {
|
||||
return this.objectMapper.fromJson(parser, (Type) headerType);
|
||||
@@ -111,8 +111,8 @@ abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessage
|
||||
}
|
||||
|
||||
protected abstract Message<?> parseWithHeaders(P parser, String jsonMessage,
|
||||
@Nullable Map<String, Object> headers) throws Exception;
|
||||
@Nullable Map<String, Object> headers);
|
||||
|
||||
protected abstract P createJsonParser(String jsonMessage) throws Exception;
|
||||
protected abstract P createJsonParser(String jsonMessage);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -57,17 +58,17 @@ public abstract class AbstractJacksonJsonObjectMapper<N, P, J> extends JsonObjec
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Object json, Class<T> valueType) throws Exception {
|
||||
return this.fromJson(json, this.constructType(valueType));
|
||||
public <T> T fromJson(Object json, Class<T> valueType) throws IOException {
|
||||
return fromJson(json, this.constructType(valueType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws Exception {
|
||||
J javaType = this.extractJavaType(javaTypes);
|
||||
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws IOException {
|
||||
J javaType = extractJavaType(javaTypes);
|
||||
return this.fromJson(json, javaType);
|
||||
}
|
||||
|
||||
protected J createJavaType(Map<String, Object> javaTypes, String javaTypeKey) throws Exception {
|
||||
protected J createJavaType(Map<String, Object> javaTypes, String javaTypeKey) {
|
||||
Object classValue = javaTypes.get(javaTypeKey);
|
||||
if (classValue == null) {
|
||||
throw new IllegalArgumentException("Could not resolve '" + javaTypeKey + "' in 'javaTypes'.");
|
||||
@@ -78,16 +79,21 @@ public abstract class AbstractJacksonJsonObjectMapper<N, P, J> extends JsonObjec
|
||||
aClass = (Class<?>) classValue;
|
||||
}
|
||||
else {
|
||||
aClass = ClassUtils.forName(classValue.toString(), this.classLoader);
|
||||
try {
|
||||
aClass = ClassUtils.forName(classValue.toString(), this.classLoader);
|
||||
}
|
||||
catch (ClassNotFoundException | LinkageError e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return this.constructType(aClass);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract <T> T fromJson(Object json, J type) throws Exception;
|
||||
protected abstract <T> T fromJson(Object json, J type) throws IOException;
|
||||
|
||||
protected abstract J extractJavaType(Map<String, Object> javaTypes) throws Exception;
|
||||
protected abstract J extractJavaType(Map<String, Object> javaTypes);
|
||||
|
||||
protected abstract J constructType(Type type);
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public abstract class AbstractJsonInboundMessageMapper<P> implements InboundMess
|
||||
this.mapToPayload = mapToPayload;
|
||||
}
|
||||
|
||||
protected abstract Object readPayload(P parser, String jsonMessage) throws Exception;
|
||||
protected abstract Object readPayload(P parser, String jsonMessage);
|
||||
|
||||
protected abstract Map<String, Object> readHeaders(P parser, String jsonMessage) throws Exception;
|
||||
protected abstract Map<String, Object> readHeaders(P parser, String jsonMessage);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PipedReader;
|
||||
import java.io.PipedWriter;
|
||||
@@ -80,7 +81,7 @@ public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Ob
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJson(Object value) throws Exception {
|
||||
public String toJson(Object value) {
|
||||
return this.objectMapper.writeValueAsString(value);
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Ob
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> toJsonNode(final Object value) throws Exception {
|
||||
public Map<String, Object> toJsonNode(final Object value) throws IOException {
|
||||
PipedReader in = new PipedReader();
|
||||
final PipedWriter out = new PipedWriter(in);
|
||||
Executors.newSingleThreadExecutor().execute(() -> toJson(value, out));
|
||||
@@ -99,7 +100,7 @@ public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Ob
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Object json, Class<T> type) throws Exception {
|
||||
public <T> T fromJson(Object json, Class<T> type) {
|
||||
if (json instanceof String) {
|
||||
return this.objectMapper.readValue((String) json, type);
|
||||
}
|
||||
@@ -126,14 +127,14 @@ public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Ob
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws Exception {
|
||||
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws IOException {
|
||||
JsonParserAndMapper parser = this.objectMapper.parser();
|
||||
|
||||
Class<?> classType = this.createJavaType(javaTypes, JsonHeaders.TYPE_ID);
|
||||
Class<?> classType = createJavaType(javaTypes, JsonHeaders.TYPE_ID);
|
||||
|
||||
Class<?> contentClassType = this.createJavaType(javaTypes, JsonHeaders.CONTENT_TYPE_ID);
|
||||
Class<?> contentClassType = createJavaType(javaTypes, JsonHeaders.CONTENT_TYPE_ID);
|
||||
|
||||
Class<?> keyClassType = this.createJavaType(javaTypes, JsonHeaders.KEY_TYPE_ID);
|
||||
Class<?> keyClassType = createJavaType(javaTypes, JsonHeaders.KEY_TYPE_ID);
|
||||
|
||||
if (keyClassType != null) {
|
||||
logger.warn("Boon doesn't support the Map 'key' conversion. Will be returned raw Map<String, Object>");
|
||||
@@ -190,13 +191,18 @@ public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Ob
|
||||
return (T) fromJson(json, classType);
|
||||
}
|
||||
|
||||
protected Class<?> createJavaType(Map<String, Object> javaTypes, String javaTypeKey) throws Exception {
|
||||
protected Class<?> createJavaType(Map<String, Object> javaTypes, String javaTypeKey) {
|
||||
Object classValue = javaTypes.get(javaTypeKey);
|
||||
if (classValue instanceof Class<?>) {
|
||||
return (Class<?>) classValue;
|
||||
}
|
||||
else if (classValue != null) {
|
||||
return ClassUtils.forName(classValue.toString(), this.classLoader);
|
||||
try {
|
||||
return ClassUtils.forName(classValue.toString(), this.classLoader);
|
||||
}
|
||||
catch (ClassNotFoundException | LinkageError e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -204,7 +210,7 @@ public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Ob
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Object parser, Type valueType) throws Exception {
|
||||
public <T> T fromJson(Object parser, Type valueType) {
|
||||
throw new UnsupportedOperationException("Boon doesn't support JSON reader parser abstraction");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
* Copyright 2017-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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -36,6 +37,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
@@ -154,9 +156,8 @@ public class EmbeddedJsonHeadersMessageMapper implements BytesMessageMapper {
|
||||
return Arrays.asList(this.headerPatterns);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public byte[] fromMessage(Message<?> message) throws Exception {
|
||||
public byte[] fromMessage(Message<?> message) {
|
||||
Map<String, Object> headersToEncode =
|
||||
this.allHeaders
|
||||
? message.getHeaders()
|
||||
@@ -179,7 +180,12 @@ public class EmbeddedJsonHeadersMessageMapper implements BytesMessageMapper {
|
||||
messageToEncode = new MutableMessage<>(message.getPayload(), headersToEncode);
|
||||
}
|
||||
|
||||
return this.objectMapper.writeValueAsBytes(messageToEncode);
|
||||
try {
|
||||
return this.objectMapper.writeValueAsBytes(messageToEncode);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,14 +203,19 @@ public class EmbeddedJsonHeadersMessageMapper implements BytesMessageMapper {
|
||||
: PatternMatchUtils.smartMatchIgnoreCase(header, this.headerPatterns));
|
||||
}
|
||||
|
||||
private byte[] fromBytesPayload(byte[] payload, Map<String, Object> headersToEncode) throws Exception {
|
||||
byte[] headers = this.objectMapper.writeValueAsBytes(headersToEncode);
|
||||
ByteBuffer buffer = ByteBuffer.wrap(new byte[8 + headers.length + payload.length]);
|
||||
buffer.putInt(headers.length);
|
||||
buffer.put(headers);
|
||||
buffer.putInt(payload.length);
|
||||
buffer.put(payload);
|
||||
return buffer.array();
|
||||
private byte[] fromBytesPayload(byte[] payload, Map<String, Object> headersToEncode) {
|
||||
try {
|
||||
byte[] headers = this.objectMapper.writeValueAsBytes(headersToEncode);
|
||||
ByteBuffer buffer = ByteBuffer.wrap(new byte[8 + headers.length + payload.length]);
|
||||
buffer.putInt(headers.length);
|
||||
buffer.put(headers);
|
||||
buffer.putInt(payload.length);
|
||||
buffer.put(payload);
|
||||
return buffer.array();
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +224,7 @@ public class EmbeddedJsonHeadersMessageMapper implements BytesMessageMapper {
|
||||
try {
|
||||
message = decodeNativeFormat(bytes, headers);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (@SuppressWarnings("unused") Exception e) {
|
||||
// empty
|
||||
}
|
||||
if (message == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -17,6 +17,8 @@
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -49,42 +51,52 @@ public class Jackson2JsonMessageParser extends AbstractJacksonJsonMessageParser<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonParser createJsonParser(String jsonMessage) throws Exception {
|
||||
return new JsonFactory().createParser(jsonMessage);
|
||||
protected JsonParser createJsonParser(String jsonMessage) {
|
||||
try {
|
||||
return new JsonFactory().createParser(jsonMessage);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Message<?> parseWithHeaders(JsonParser parser, String jsonMessage,
|
||||
@Nullable Map<String, Object> headersToAdd) throws Exception {
|
||||
@Nullable Map<String, Object> headersToAdd) {
|
||||
|
||||
String error = AbstractJsonInboundMessageMapper.MESSAGE_FORMAT_ERROR + jsonMessage;
|
||||
Assert.isTrue(JsonToken.START_OBJECT == parser.nextToken(), error);
|
||||
Map<String, Object> headers = null;
|
||||
Object payload = null;
|
||||
while (JsonToken.END_OBJECT != parser.nextToken()) {
|
||||
Assert.isTrue(JsonToken.FIELD_NAME == parser.getCurrentToken(), error);
|
||||
boolean isHeadersToken = "headers".equals(parser.getCurrentName());
|
||||
boolean isPayloadToken = "payload".equals(parser.getCurrentName());
|
||||
Assert.isTrue(isHeadersToken || isPayloadToken, error);
|
||||
if (isHeadersToken) {
|
||||
Assert.isTrue(parser.nextToken() == JsonToken.START_OBJECT, error);
|
||||
headers = readHeaders(parser, jsonMessage);
|
||||
}
|
||||
else if (isPayloadToken) {
|
||||
parser.nextToken();
|
||||
payload = this.readPayload(parser, jsonMessage);
|
||||
try {
|
||||
String error = AbstractJsonInboundMessageMapper.MESSAGE_FORMAT_ERROR + jsonMessage;
|
||||
Assert.isTrue(JsonToken.START_OBJECT == parser.nextToken(), error);
|
||||
Map<String, Object> headers = null;
|
||||
Object payload = null;
|
||||
while (JsonToken.END_OBJECT != parser.nextToken()) {
|
||||
Assert.isTrue(JsonToken.FIELD_NAME == parser.getCurrentToken(), error);
|
||||
boolean isHeadersToken = "headers".equals(parser.getCurrentName());
|
||||
boolean isPayloadToken = "payload".equals(parser.getCurrentName());
|
||||
Assert.isTrue(isHeadersToken || isPayloadToken, error);
|
||||
if (isHeadersToken) {
|
||||
Assert.isTrue(parser.nextToken() == JsonToken.START_OBJECT, error);
|
||||
headers = readHeaders(parser, jsonMessage);
|
||||
}
|
||||
else if (isPayloadToken) {
|
||||
parser.nextToken();
|
||||
payload = this.readPayload(parser, jsonMessage);
|
||||
}
|
||||
}
|
||||
Assert.notNull(headers, error);
|
||||
|
||||
return getMessageBuilderFactory()
|
||||
.withPayload(payload)
|
||||
.copyHeaders(headers)
|
||||
.copyHeadersIfAbsent(headersToAdd)
|
||||
.build();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
Assert.notNull(headers, error);
|
||||
|
||||
return getMessageBuilderFactory()
|
||||
.withPayload(payload)
|
||||
.copyHeaders(headers)
|
||||
.copyHeadersIfAbsent(headersToAdd)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Map<String, Object> readHeaders(JsonParser parser, String jsonMessage) throws Exception {
|
||||
private Map<String, Object> readHeaders(JsonParser parser, String jsonMessage) throws IOException {
|
||||
Map<String, Object> headers = new LinkedHashMap<>();
|
||||
while (JsonToken.END_OBJECT != parser.nextToken()) {
|
||||
String headerName = parser.getCurrentName();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
@@ -32,6 +33,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -82,17 +84,17 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJson(Object value) throws Exception {
|
||||
public String toJson(Object value) throws JsonProcessingException {
|
||||
return this.objectMapper.writeValueAsString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJson(Object value, Writer writer) throws Exception {
|
||||
public void toJson(Object value, Writer writer) throws IOException {
|
||||
this.objectMapper.writeValue(writer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonNode toJsonNode(Object json) throws Exception {
|
||||
public JsonNode toJsonNode(Object json) throws IOException {
|
||||
try {
|
||||
if (json instanceof String) {
|
||||
return this.objectMapper.readTree((String) json);
|
||||
@@ -124,7 +126,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T fromJson(Object json, JavaType type) throws Exception {
|
||||
protected <T> T fromJson(Object json, JavaType type) throws IOException {
|
||||
if (json instanceof String) {
|
||||
return this.objectMapper.readValue((String) json, type);
|
||||
}
|
||||
@@ -150,13 +152,13 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(JsonParser parser, Type valueType) throws Exception {
|
||||
public <T> T fromJson(JsonParser parser, Type valueType) throws IOException {
|
||||
return this.objectMapper.readValue(parser, constructType(valueType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
protected JavaType extractJavaType(Map<String, Object> javaTypes) throws Exception {
|
||||
protected JavaType extractJavaType(Map<String, Object> javaTypes) {
|
||||
JavaType classType = this.createJavaType(javaTypes, JsonHeaders.TYPE_ID);
|
||||
if (!classType.isContainerType() || classType.isArrayType()) {
|
||||
return classType;
|
||||
@@ -169,7 +171,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
contentClassType);
|
||||
}
|
||||
|
||||
JavaType keyClassType = this.createJavaType(javaTypes, JsonHeaders.KEY_TYPE_ID);
|
||||
JavaType keyClassType = createJavaType(javaTypes, JsonHeaders.KEY_TYPE_ID);
|
||||
return this.objectMapper.getTypeFactory()
|
||||
.constructMapType((Class<? extends Map<?, ?>>) classType.getRawClass(), keyClassType, contentClassType);
|
||||
}
|
||||
@@ -186,7 +188,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.jdk7.Jdk7Module", getClassLoader());
|
||||
this.objectMapper.registerModule(BeanUtils.instantiateClass(jdk7Module));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
catch (@SuppressWarnings("unused") ClassNotFoundException ex) {
|
||||
// jackson-datatype-jdk7 not available
|
||||
}
|
||||
|
||||
@@ -195,7 +197,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.jdk8.Jdk8Module", getClassLoader());
|
||||
this.objectMapper.registerModule(BeanUtils.instantiateClass(jdk8Module));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
catch (@SuppressWarnings("unused") ClassNotFoundException ex) {
|
||||
// jackson-datatype-jdk8 not available
|
||||
}
|
||||
|
||||
@@ -204,7 +206,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.jsr310.JavaTimeModule", getClassLoader());
|
||||
this.objectMapper.registerModule(BeanUtils.instantiateClass(javaTimeModule));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
catch (@SuppressWarnings("unused") ClassNotFoundException ex) {
|
||||
// jackson-datatype-jsr310 not available
|
||||
}
|
||||
|
||||
@@ -215,7 +217,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
ClassUtils.forName("com.fasterxml.jackson.datatype.joda.JodaModule", getClassLoader());
|
||||
this.objectMapper.registerModule(BeanUtils.instantiateClass(jodaModule));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
catch (@SuppressWarnings("unused") ClassNotFoundException ex) {
|
||||
// jackson-datatype-joda not available
|
||||
}
|
||||
}
|
||||
@@ -227,7 +229,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
|
||||
ClassUtils.forName("com.fasterxml.jackson.module.kotlin.KotlinModule", getClassLoader());
|
||||
this.objectMapper.registerModule(BeanUtils.instantiateClass(kotlinModule));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
catch (@SuppressWarnings("unused") ClassNotFoundException ex) {
|
||||
//jackson-module-kotlin not available
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -65,26 +65,26 @@ public class JsonInboundMessageMapper extends AbstractJsonInboundMessageMapper<J
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<?> toMessage(String jsonMessage, @Nullable Map<String, Object> headers) throws Exception {
|
||||
public Message<?> toMessage(String jsonMessage, @Nullable Map<String, Object> headers) {
|
||||
return this.messageParser.doInParser(this, jsonMessage, headers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> readHeaders(JsonMessageParser<?> parser, String jsonMessage) throws Exception {
|
||||
protected Map<String, Object> readHeaders(JsonMessageParser<?> parser, String jsonMessage) {
|
||||
//No-op
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object readPayload(JsonMessageParser<?> parser, String jsonMessage) throws Exception {
|
||||
protected Object readPayload(JsonMessageParser<?> parser, String jsonMessage) {
|
||||
//No-op
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface JsonMessageParser<P> {
|
||||
public interface JsonMessageParser<P> { // NOSONAR unused P
|
||||
|
||||
Message<?> doInParser(JsonInboundMessageMapper messageMapper, String jsonMessage,
|
||||
@Nullable Map<String, Object> headers) throws Exception;
|
||||
@Nullable Map<String, Object> headers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
@@ -32,17 +33,17 @@ import java.util.Map;
|
||||
*/
|
||||
public interface JsonObjectMapper<N, P> {
|
||||
|
||||
String toJson(Object value) throws Exception;
|
||||
String toJson(Object value) throws IOException;
|
||||
|
||||
void toJson(Object value, Writer writer) throws Exception;
|
||||
void toJson(Object value, Writer writer) throws IOException;
|
||||
|
||||
N toJsonNode(Object value) throws Exception;
|
||||
N toJsonNode(Object value) throws IOException;
|
||||
|
||||
<T> T fromJson(Object json, Class<T> valueType) throws Exception;
|
||||
<T> T fromJson(Object json, Class<T> valueType) throws IOException;
|
||||
|
||||
<T> T fromJson(Object json, Map<String, Object> javaTypes) throws Exception;
|
||||
<T> T fromJson(Object json, Map<String, Object> javaTypes) throws IOException;
|
||||
|
||||
<T> T fromJson(P parser, Type valueType) throws Exception;
|
||||
<T> T fromJson(P parser, Type valueType) throws IOException;
|
||||
|
||||
void populateJavaTypes(Map<String, Object> map, Object object);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
@@ -34,31 +35,31 @@ import org.springframework.integration.mapping.support.JsonHeaders;
|
||||
public abstract class JsonObjectMapperAdapter<N, P> implements JsonObjectMapper<N, P> {
|
||||
|
||||
@Override
|
||||
public String toJson(Object value) throws Exception {
|
||||
public String toJson(Object value) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJson(Object value, Writer writer) throws Exception {
|
||||
public void toJson(Object value, Writer writer) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public N toJsonNode(Object value) throws Exception {
|
||||
public N toJsonNode(Object value) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Object json, Class<T> valueType) throws Exception {
|
||||
public <T> T fromJson(Object json, Class<T> valueType) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(P parser, Type valueType) throws Exception {
|
||||
public <T> T fromJson(P parser, Type valueType) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws Exception {
|
||||
public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.integration.support.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
import org.springframework.integration.mapping.OutboundMessageMapper;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -53,8 +56,13 @@ public class JsonOutboundMessageMapper implements OutboundMessageMapper<String>
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fromMessage(Message<?> message) throws Exception {
|
||||
return this.jsonObjectMapper.toJson(this.shouldExtractPayload ? message.getPayload() : message);
|
||||
public String fromMessage(Message<?> message) {
|
||||
try {
|
||||
return this.jsonObjectMapper.toJson(this.shouldExtractPayload ? message.getPayload() : message);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class AbstractServerConnectionFactory extends AbstractConnection
|
||||
* method cannot discriminate.
|
||||
*/
|
||||
@Override
|
||||
public TcpConnection getConnection() throws Exception {
|
||||
public TcpConnection getConnection() {
|
||||
throw new UnsupportedOperationException("Getting a connection from a server factory is not supported");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2011 the original author or authors.
|
||||
* Copyright 2001-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.
|
||||
@@ -29,6 +29,6 @@ import org.springframework.context.Lifecycle;
|
||||
*/
|
||||
public interface ConnectionFactory extends Lifecycle {
|
||||
|
||||
TcpConnection getConnection() throws Exception;
|
||||
TcpConnection getConnection() throws InterruptedException;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -42,7 +42,7 @@ public class MessageConvertingTcpMessageMapper extends TcpMessageMapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<?> toMessage(TcpConnection connection, @Nullable Map<String, Object> headers) throws Exception {
|
||||
public Message<?> toMessage(TcpConnection connection, @Nullable Map<String, Object> headers) {
|
||||
Object data = connection.getPayload();
|
||||
if (data != null) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MessageConvertingTcpMessageMapper extends TcpMessageMapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromMessage(Message<?> message) throws Exception {
|
||||
public Object fromMessage(Message<?> message) {
|
||||
return this.messageConverter.fromMessage(message, Object.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -171,7 +171,7 @@ public class TcpMessageMapper implements
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Message<?> toMessage(TcpConnection connection, @Nullable Map<String, Object> headers) throws Exception {
|
||||
public Message<?> toMessage(TcpConnection connection, @Nullable Map<String, Object> headers) {
|
||||
Message<Object> message = null;
|
||||
Object payload = connection.getPayload();
|
||||
if (payload != null) {
|
||||
@@ -244,7 +244,7 @@ public class TcpMessageMapper implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromMessage(Message<?> message) throws Exception {
|
||||
public Object fromMessage(Message<?> message) {
|
||||
if (this.bytesMessageMapper != null) {
|
||||
return this.bytesMessageMapper.fromMessage(message);
|
||||
}
|
||||
|
||||
@@ -339,10 +339,10 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
* Blocks until a complete message has been assembled.
|
||||
* Synchronized to avoid concurrency.
|
||||
* @return The Message or null if no data is available.
|
||||
* @throws IOException
|
||||
* @throws IOException an IO exception
|
||||
*/
|
||||
@Nullable
|
||||
private synchronized Message<?> convert() throws Exception {
|
||||
private synchronized Message<?> convert() throws IOException {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace(getConnectionId() + " checking data avail (convert): " + this.channelInputStream.available() +
|
||||
" pending: " + (this.writingToPipe));
|
||||
@@ -369,13 +369,13 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
}
|
||||
catch (Exception e) {
|
||||
closeConnection(true);
|
||||
if (e instanceof SocketTimeoutException) {
|
||||
if (e instanceof SocketTimeoutException) { // NOSONAR instanceof
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Closing socket after timeout " + getConnectionId());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(e instanceof SoftEndOfStreamException)) {
|
||||
if (!(e instanceof SoftEndOfStreamException)) { // NOSONAR instanceof
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private void doRead() throws Exception {
|
||||
private void doRead() throws IOException {
|
||||
if (this.rawBuffer == null) {
|
||||
this.rawBuffer = allocate(this.maxMessageSize);
|
||||
}
|
||||
@@ -447,7 +447,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
catch (RejectedExecutionException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (IOException e) {
|
||||
publishConnectionExceptionEvent(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ public class SocketSupportTests {
|
||||
assertThatExceptionOfType(MessagingException.class)
|
||||
.isThrownBy(() -> testNioClientAndServerSSLDifferentContexts(true))
|
||||
.withMessageMatching(".*(Socket closed during SSL Handshake|Broken pipe"
|
||||
+ "|Connection reset by peer|AsynchronousCloseException).*");
|
||||
+ "|Connection reset by peer|AsynchronousCloseException|ClosedChannelException).*");
|
||||
}
|
||||
|
||||
private void testNioClientAndServerSSLDifferentContexts(boolean badClient) throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -391,10 +391,9 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
* is not 1, a warning will be logged. When using the {@link JdbcChannelMessageStore}
|
||||
* with Oracle, the fetchSize value of 1 is needed to ensure FIFO characteristics
|
||||
* of polled messages. Please see the Oracle {@link ChannelMessageStoreQueryProvider} for more details.
|
||||
* @throws Exception Any Exception.
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
Assert.state(this.jdbcTemplate != null, "A DataSource or JdbcTemplate must be provided");
|
||||
Assert.notNull(this.channelMessageStoreQueryProvider, "A channelMessageStoreQueryProvider must be provided.");
|
||||
|
||||
@@ -428,7 +427,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
ps -> this.preparedStatementSetter.setValues(ps, message, groupId, this.region,
|
||||
this.priorityEnabled));
|
||||
}
|
||||
catch (DuplicateKeyException e) {
|
||||
catch (@SuppressWarnings("unused") DuplicateKeyException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
String messageId = getKey(message.getHeaders().getId());
|
||||
logger.debug("The Message with id [" + messageId + "] already exists.\nIgnoring INSERT...");
|
||||
|
||||
@@ -507,11 +507,11 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
"No requestDestination, requestDestinationName, or requestDestinationExpression has been configured.");
|
||||
}
|
||||
|
||||
private Destination resolveRequestDestination(String requestDestinationName, Session session) throws JMSException {
|
||||
private Destination resolveRequestDestination(String reqDestinationName, Session session) throws JMSException {
|
||||
Assert.notNull(this.destinationResolver,
|
||||
"DestinationResolver is required when relying upon the 'requestDestinationName' property.");
|
||||
return this.destinationResolver.resolveDestinationName(
|
||||
session, requestDestinationName, this.requestPubSubDomain);
|
||||
session, reqDestinationName, this.requestPubSubDomain);
|
||||
}
|
||||
|
||||
private Destination determineReplyDestination(Message<?> message, Session session) throws JMSException {
|
||||
@@ -536,11 +536,11 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
return session.createTemporaryQueue();
|
||||
}
|
||||
|
||||
private Destination resolveReplyDestination(String replyDestinationName, Session session) throws JMSException {
|
||||
private Destination resolveReplyDestination(String repDestinationName, Session session) throws JMSException {
|
||||
Assert.notNull(this.destinationResolver,
|
||||
"DestinationResolver is required when relying upon the 'replyDestinationName' property.");
|
||||
return this.destinationResolver.resolveDestinationName(
|
||||
session, replyDestinationName, this.replyPubSubDomain);
|
||||
session, repDestinationName, this.replyPubSubDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -929,11 +929,11 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
* Creates the MessageConsumer before sending the request Message since we are generating
|
||||
* our own correlationId value for the MessageSelector.
|
||||
*/
|
||||
private javax.jms.Message doSendAndReceiveWithGeneratedCorrelationId(Destination requestDestination,
|
||||
private javax.jms.Message doSendAndReceiveWithGeneratedCorrelationId(Destination reqDestination,
|
||||
javax.jms.Message jmsRequest, Destination replyTo, Session session, int priority) throws JMSException {
|
||||
MessageProducer messageProducer = null;
|
||||
try {
|
||||
messageProducer = session.createProducer(requestDestination);
|
||||
messageProducer = session.createProducer(reqDestination);
|
||||
Assert.state(this.correlationKey != null, "correlationKey must not be null");
|
||||
String messageSelector = null;
|
||||
if (!this.correlationKey.equals("JMSCorrelationID*") || jmsRequest.getJMSCorrelationID() == null) {
|
||||
@@ -963,12 +963,13 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
/**
|
||||
* Creates the MessageConsumer before sending the request Message since we do not need any correlation.
|
||||
*/
|
||||
private javax.jms.Message doSendAndReceiveWithTemporaryReplyToDestination(Destination requestDestination,
|
||||
private javax.jms.Message doSendAndReceiveWithTemporaryReplyToDestination(Destination reqDestination,
|
||||
javax.jms.Message jmsRequest, Destination replyTo, Session session, int priority) throws JMSException {
|
||||
|
||||
MessageProducer messageProducer = null;
|
||||
MessageConsumer messageConsumer = null;
|
||||
try {
|
||||
messageProducer = session.createProducer(requestDestination);
|
||||
messageProducer = session.createProducer(reqDestination);
|
||||
messageConsumer = session.createConsumer(replyTo);
|
||||
this.sendRequestMessage(jmsRequest, messageProducer, priority);
|
||||
return this.receiveReplyMessage(messageConsumer);
|
||||
@@ -983,8 +984,9 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
* Creates the MessageConsumer after sending the request Message since we need
|
||||
* the MessageID for correlation with a MessageSelector.
|
||||
*/
|
||||
private javax.jms.Message doSendAndReceiveWithMessageIdCorrelation(Destination requestDestination,
|
||||
private javax.jms.Message doSendAndReceiveWithMessageIdCorrelation(Destination reqDestination,
|
||||
javax.jms.Message jmsRequest, Destination replyTo, Session session, int priority) throws JMSException {
|
||||
|
||||
if (replyTo instanceof Topic && logger.isWarnEnabled()) {
|
||||
logger.warn("Relying on the MessageID for correlation is not recommended when using a Topic as the replyTo Destination " +
|
||||
"because that ID can only be provided to a MessageSelector after the request Message has been sent thereby " +
|
||||
@@ -994,7 +996,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
MessageProducer messageProducer = null;
|
||||
try {
|
||||
messageProducer = session.createProducer(requestDestination);
|
||||
messageProducer = session.createProducer(reqDestination);
|
||||
this.sendRequestMessage(jmsRequest, messageProducer, priority);
|
||||
String messageId = jmsRequest.getJMSMessageID().replaceAll("'", "''");
|
||||
String messageSelector = "JMSCorrelationID = '" + messageId + "'";
|
||||
@@ -1053,7 +1055,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
catch (InterruptedException e1) {
|
||||
catch (@SuppressWarnings("unused") InterruptedException e1) {
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
}
|
||||
@@ -1079,13 +1081,13 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
}
|
||||
|
||||
private Object doSendAndReceiveAsync(Destination requestDestination, javax.jms.Message jmsRequest, Session session,
|
||||
private Object doSendAndReceiveAsync(Destination reqDestination, javax.jms.Message jmsRequest, Session session,
|
||||
int priority) throws JMSException {
|
||||
|
||||
String correlation = null;
|
||||
MessageProducer messageProducer = null;
|
||||
try {
|
||||
messageProducer = session.createProducer(requestDestination);
|
||||
messageProducer = session.createProducer(reqDestination);
|
||||
correlation = this.gatewayCorrelation + "_" + Long.toString(this.correlationId.incrementAndGet());
|
||||
if (this.correlationKey.equals("JMSCorrelationID")) {
|
||||
jmsRequest.setJMSCorrelationID(correlation);
|
||||
@@ -1129,14 +1131,14 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
}
|
||||
|
||||
private javax.jms.Message doSendAndReceiveAsyncDefaultCorrelation(Destination requestDestination,
|
||||
private javax.jms.Message doSendAndReceiveAsyncDefaultCorrelation(Destination reqDestination,
|
||||
javax.jms.Message jmsRequest, Session session, int priority) throws JMSException {
|
||||
|
||||
String correlation = null;
|
||||
MessageProducer messageProducer = null;
|
||||
|
||||
try {
|
||||
messageProducer = session.createProducer(requestDestination);
|
||||
messageProducer = session.createProducer(reqDestination);
|
||||
LinkedBlockingQueue<javax.jms.Message> replyQueue = new LinkedBlockingQueue<javax.jms.Message>(1);
|
||||
|
||||
this.sendRequestMessage(jmsRequest, messageProducer, priority);
|
||||
@@ -1171,7 +1173,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
}
|
||||
|
||||
private javax.jms.Message obtainReplyFromContainer(String correlationId,
|
||||
private javax.jms.Message obtainReplyFromContainer(String correlnId,
|
||||
LinkedBlockingQueue<javax.jms.Message> replyQueue) {
|
||||
javax.jms.Message reply = null;
|
||||
|
||||
@@ -1190,28 +1192,28 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (reply == null) {
|
||||
logger.debug(this.getComponentName() + " Timed out waiting for reply with CorrelationId "
|
||||
+ correlationId);
|
||||
+ correlnId);
|
||||
}
|
||||
else {
|
||||
logger.debug(this.getComponentName() + " Obtained reply with CorrelationId " + correlationId);
|
||||
logger.debug(this.getComponentName() + " Obtained reply with CorrelationId " + correlnId);
|
||||
}
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
private SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> createFuture(final String correlationId) {
|
||||
private SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> createFuture(final String correlnId) {
|
||||
SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> future =
|
||||
new SettableListenableFuture<AbstractIntegrationMessageBuilder<?>>();
|
||||
this.futures.put(correlationId, future);
|
||||
this.futures.put(correlnId, future);
|
||||
if (this.receiveTimeout > 0) {
|
||||
getTaskScheduler().schedule((Runnable) () -> expire(correlationId),
|
||||
getTaskScheduler().schedule((Runnable) () -> expire(correlnId),
|
||||
new Date(System.currentTimeMillis() + this.receiveTimeout));
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
private void expire(String correlationId) {
|
||||
final SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> future = this.futures.remove(correlationId);
|
||||
private void expire(String correlnId) {
|
||||
final SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> future = this.futures.remove(correlnId);
|
||||
if (future != null) {
|
||||
try {
|
||||
if (getRequiresReply()) {
|
||||
@@ -1219,12 +1221,12 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Reply expired and reply not required for " + correlationId);
|
||||
logger.debug("Reply expired and reply not required for " + correlnId);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Exception while expiring future");
|
||||
logger.error("Exception while expiring future", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1257,7 +1259,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
((TemporaryTopic) destination).delete();
|
||||
}
|
||||
}
|
||||
catch (JMSException e) {
|
||||
catch (@SuppressWarnings("unused") JMSException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
@@ -1313,50 +1315,50 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
}
|
||||
|
||||
private void onMessageAsync(javax.jms.Message message, String correlationId) throws Exception {
|
||||
SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> future = this.futures.remove(correlationId);
|
||||
private void onMessageAsync(javax.jms.Message message, String correlnId) throws JMSException {
|
||||
SettableListenableFuture<AbstractIntegrationMessageBuilder<?>> future = this.futures.remove(correlnId);
|
||||
if (future != null) {
|
||||
message.setJMSCorrelationID(null);
|
||||
future.set(buildReply(message));
|
||||
}
|
||||
else {
|
||||
logger.warn("Late reply for " + correlationId);
|
||||
logger.warn("Late reply for " + correlnId);
|
||||
}
|
||||
}
|
||||
|
||||
private void onMessageSync(javax.jms.Message message, String correlationId) {
|
||||
private void onMessageSync(javax.jms.Message message, String correlnId) {
|
||||
try {
|
||||
LinkedBlockingQueue<javax.jms.Message> queue = this.replies.get(correlationId);
|
||||
LinkedBlockingQueue<javax.jms.Message> queue = this.replies.get(correlnId);
|
||||
if (queue == null) {
|
||||
if (this.correlationKey != null) {
|
||||
Log debugLogger = LogFactory.getLog("si.jmsgateway.debug");
|
||||
if (debugLogger.isDebugEnabled()) {
|
||||
Object siMessage = this.messageConverter.fromMessage(message);
|
||||
debugLogger.debug("No pending reply for " + siMessage + " with correlationId: "
|
||||
+ correlationId + " pending replies: " + this.replies.keySet());
|
||||
+ correlnId + " pending replies: " + this.replies.keySet());
|
||||
}
|
||||
throw new RuntimeException("No sender waiting for reply");
|
||||
}
|
||||
synchronized (this.earlyOrLateReplies) {
|
||||
queue = this.replies.get(correlationId);
|
||||
queue = this.replies.get(correlnId);
|
||||
if (queue == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Reply for correlationId " + correlationId + " received early or late");
|
||||
logger.debug("Reply for correlationId " + correlnId + " received early or late");
|
||||
}
|
||||
this.earlyOrLateReplies.put(correlationId, new TimedReply(message));
|
||||
this.earlyOrLateReplies.put(correlnId, new TimedReply(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (queue != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received reply with correlationId " + correlationId);
|
||||
logger.debug("Received reply with correlationId " + correlnId);
|
||||
}
|
||||
queue.add(message);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to consume reply with correlationId " + correlationId, e);
|
||||
logger.warn("Failed to consume reply with correlationId " + correlnId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1408,7 +1410,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (@SuppressWarnings("unused") InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Container did not establish a destination");
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ import javax.jms.Session;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.config.AbstractFactoryBean;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.jms.AbstractJmsChannel;
|
||||
import org.springframework.integration.jms.DynamicJmsTemplate;
|
||||
import org.springframework.integration.jms.PollableJmsChannel;
|
||||
import org.springframework.integration.jms.SubscribableJmsChannel;
|
||||
import org.springframework.integration.util.JavaUtils;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
@@ -54,7 +54,7 @@ import org.springframework.util.StringUtils;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChannel>
|
||||
implements SmartLifecycle, DisposableBean, BeanNameAware {
|
||||
implements SmartLifecycle, BeanNameAware {
|
||||
|
||||
private volatile AbstractJmsChannel channel;
|
||||
|
||||
@@ -372,7 +372,7 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractJmsChannel createInstance() throws Exception {
|
||||
protected AbstractJmsChannel createInstance() {
|
||||
this.initializeJmsTemplate();
|
||||
if (this.messageDriven) {
|
||||
this.listenerContainer = createContainer();
|
||||
@@ -384,9 +384,8 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
Assert.isTrue(!Boolean.TRUE.equals(this.pubSubDomain),
|
||||
"A JMS Topic-backed 'publish-subscribe-channel' must be message-driven.");
|
||||
PollableJmsChannel pollableJmschannel = new PollableJmsChannel(this.jmsTemplate);
|
||||
if (this.messageSelector != null) {
|
||||
pollableJmschannel.setMessageSelector(this.messageSelector);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.messageSelector, pollableJmschannel::setMessageSelector);
|
||||
this.channel = pollableJmschannel;
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(this.interceptors)) {
|
||||
@@ -394,9 +393,8 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
}
|
||||
this.channel.setBeanName(this.beanName);
|
||||
BeanFactory beanFactory = this.getBeanFactory();
|
||||
if (beanFactory != null) {
|
||||
this.channel.setBeanFactory(beanFactory);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(beanFactory, this.channel::setBeanFactory);
|
||||
this.channel.afterPropertiesSet();
|
||||
return this.channel;
|
||||
}
|
||||
@@ -404,45 +402,39 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
private void initializeJmsTemplate() {
|
||||
Assert.isTrue(this.destination != null ^ this.destinationName != null,
|
||||
"Exactly one of destination or destinationName is required.");
|
||||
if (this.destination != null) {
|
||||
this.jmsTemplate.setDefaultDestination(this.destination);
|
||||
}
|
||||
if (this.destinationName != null) {
|
||||
this.jmsTemplate.setDefaultDestinationName(this.destinationName);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.destination, this.jmsTemplate::setDefaultDestination)
|
||||
.acceptIfNotNull(this.destinationName, this.jmsTemplate::setDefaultDestinationName);
|
||||
}
|
||||
|
||||
private AbstractMessageListenerContainer createContainer() throws Exception {
|
||||
private AbstractMessageListenerContainer createContainer() {
|
||||
if (this.containerType == null) {
|
||||
this.containerType = DefaultMessageListenerContainer.class;
|
||||
}
|
||||
AbstractMessageListenerContainer container = this.containerType.newInstance();
|
||||
AbstractMessageListenerContainer container;
|
||||
try {
|
||||
container = this.containerType.newInstance();
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
container.setAcceptMessagesWhileStopping(this.acceptMessagesWhileStopping);
|
||||
container.setAutoStartup(this.autoStartup);
|
||||
container.setClientId(this.clientId);
|
||||
container.setConnectionFactory(this.connectionFactory);
|
||||
if (this.destination != null) {
|
||||
container.setDestination(this.destination);
|
||||
}
|
||||
if (this.destinationName != null) {
|
||||
container.setDestinationName(this.destinationName);
|
||||
}
|
||||
if (this.destinationResolver != null) {
|
||||
container.setDestinationResolver(this.destinationResolver);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.destination, container::setDestination)
|
||||
.acceptIfNotNull(this.destinationName, container::setDestinationName)
|
||||
.acceptIfNotNull(this.destinationResolver, container::setDestinationResolver);
|
||||
container.setDurableSubscriptionName(this.durableSubscriptionName);
|
||||
container.setErrorHandler(this.errorHandler);
|
||||
container.setExceptionListener(this.exceptionListener);
|
||||
if (this.exposeListenerSession != null) {
|
||||
container.setExposeListenerSession(this.exposeListenerSession);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.exposeListenerSession, container::setExposeListenerSession);
|
||||
container.setMessageSelector(this.messageSelector);
|
||||
if (this.phase != null) {
|
||||
container.setPhase(this.phase);
|
||||
}
|
||||
if (this.pubSubDomain != null) {
|
||||
container.setPubSubDomain(this.pubSubDomain);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.phase, container::setPhase)
|
||||
.acceptIfNotNull(this.pubSubDomain, container::setPubSubDomain);
|
||||
container.setSessionAcknowledgeMode(this.sessionAcknowledgeMode);
|
||||
container.setSessionTransacted(this.sessionTransacted);
|
||||
container.setSubscriptionDurable(this.subscriptionDurable);
|
||||
@@ -452,59 +444,29 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
|
||||
if (container instanceof DefaultMessageListenerContainer) {
|
||||
DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) container;
|
||||
if (this.cacheLevelName != null) {
|
||||
dmlc.setCacheLevelName(this.cacheLevelName);
|
||||
}
|
||||
|
||||
if (this.cacheLevel != null) {
|
||||
dmlc.setCacheLevel(this.cacheLevel);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(this.concurrency)) {
|
||||
dmlc.setConcurrency(this.concurrency);
|
||||
}
|
||||
|
||||
if (this.concurrentConsumers != null) {
|
||||
dmlc.setConcurrentConsumers(this.concurrentConsumers);
|
||||
}
|
||||
|
||||
if (this.maxConcurrentConsumers != null) {
|
||||
dmlc.setMaxConcurrentConsumers(this.maxConcurrentConsumers);
|
||||
}
|
||||
|
||||
if (this.idleTaskExecutionLimit != null) {
|
||||
dmlc.setIdleTaskExecutionLimit(this.idleTaskExecutionLimit);
|
||||
}
|
||||
|
||||
if (this.maxMessagesPerTask != null) {
|
||||
dmlc.setMaxMessagesPerTask(this.maxMessagesPerTask);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.cacheLevelName, dmlc::setCacheLevelName)
|
||||
.acceptIfNotNull(this.cacheLevel, dmlc::setCacheLevel)
|
||||
.acceptIfHasText(this.concurrency, dmlc::setConcurrency)
|
||||
.acceptIfNotNull(this.concurrentConsumers, dmlc::setConcurrentConsumers)
|
||||
.acceptIfNotNull(this.maxConcurrentConsumers, dmlc::setMaxConcurrentConsumers)
|
||||
.acceptIfNotNull(this.idleTaskExecutionLimit, dmlc::setIdleTaskExecutionLimit)
|
||||
.acceptIfNotNull(this.maxMessagesPerTask, dmlc::setMaxMessagesPerTask);
|
||||
dmlc.setPubSubNoLocal(this.pubSubNoLocal);
|
||||
if (this.receiveTimeout != null) {
|
||||
dmlc.setReceiveTimeout(this.receiveTimeout);
|
||||
}
|
||||
if (this.recoveryInterval != null) {
|
||||
dmlc.setRecoveryInterval(this.recoveryInterval);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.receiveTimeout, dmlc::setReceiveTimeout)
|
||||
.acceptIfNotNull(this.recoveryInterval, dmlc::setRecoveryInterval);
|
||||
dmlc.setTaskExecutor(this.taskExecutor);
|
||||
dmlc.setTransactionManager(this.transactionManager);
|
||||
if (this.transactionName != null) {
|
||||
dmlc.setTransactionName(this.transactionName);
|
||||
}
|
||||
if (this.transactionTimeout != null) {
|
||||
dmlc.setTransactionTimeout(this.transactionTimeout);
|
||||
}
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.transactionName, dmlc::setTransactionName)
|
||||
.acceptIfNotNull(this.transactionTimeout, dmlc::setTransactionTimeout);
|
||||
}
|
||||
else if (container instanceof SimpleMessageListenerContainer) {
|
||||
SimpleMessageListenerContainer smlc = (SimpleMessageListenerContainer) container;
|
||||
if (StringUtils.hasText(this.concurrency)) {
|
||||
smlc.setConcurrency(this.concurrency);
|
||||
}
|
||||
|
||||
if (this.concurrentConsumers != null) {
|
||||
smlc.setConcurrentConsumers(this.concurrentConsumers);
|
||||
}
|
||||
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfHasText(this.concurrency, smlc::setConcurrency)
|
||||
.acceptIfNotNull(this.concurrentConsumers, smlc::setConcurrentConsumers);
|
||||
smlc.setPubSubNoLocal(this.pubSubNoLocal);
|
||||
smlc.setTaskExecutor(this.taskExecutor);
|
||||
}
|
||||
@@ -556,7 +518,7 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void destroyInstance(AbstractJmsChannel instance) throws Exception {
|
||||
protected void destroyInstance(AbstractJmsChannel instance) {
|
||||
if (instance instanceof SubscribableJmsChannel) {
|
||||
((SubscribableJmsChannel) this.channel).destroy();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-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.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.backoff.BackOff;
|
||||
public class JmsDefaultListenerContainerSpec
|
||||
extends JmsListenerContainerSpec<JmsDefaultListenerContainerSpec, DefaultMessageListenerContainer> {
|
||||
|
||||
JmsDefaultListenerContainerSpec() throws Exception {
|
||||
JmsDefaultListenerContainerSpec() {
|
||||
super(DefaultMessageListenerContainer.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-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.
|
||||
@@ -37,13 +37,22 @@ import org.springframework.util.ErrorHandler;
|
||||
public class JmsListenerContainerSpec<S extends JmsListenerContainerSpec<S, C>, C extends AbstractMessageListenerContainer>
|
||||
extends JmsDestinationAccessorSpec<S, C> {
|
||||
|
||||
JmsListenerContainerSpec(Class<C> aClass) throws Exception {
|
||||
super(aClass.newInstance());
|
||||
JmsListenerContainerSpec(Class<C> aClass) {
|
||||
super(newInstance(aClass));
|
||||
if (DefaultMessageListenerContainer.class.isAssignableFrom(aClass)) {
|
||||
this.target.setSessionTransacted(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static <C extends AbstractMessageListenerContainer> C newInstance(Class<C> aClass) {
|
||||
try {
|
||||
return aClass.newInstance();
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param destination the destination.
|
||||
* @return the spec.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -126,7 +126,7 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
if (this.mongoTemplate == null) {
|
||||
if (this.mappingMongoConverter == null) {
|
||||
this.mappingMongoConverter = new MappingMongoConverter(new DefaultDbRefResolver(this.mongoDbFactory),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -88,7 +88,7 @@ public class MongoDbChannelMessageStore extends AbstractConfigurableMongoDbMessa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
super.afterPropertiesSet();
|
||||
this.mongoTemplate.indexOps(this.collectionName)
|
||||
.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -190,7 +190,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
if (this.applicationContext != null) {
|
||||
this.converter.setApplicationContext(this.applicationContext);
|
||||
}
|
||||
@@ -353,7 +353,6 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
|
||||
|
||||
Query query = Query.query(Criteria.where(GROUP_ID_KEY).exists(true));
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterable<String> groupIds = this.template.getCollection(this.collectionName)
|
||||
.distinct(GROUP_ID_KEY, query.getQueryObject(), String.class);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ExpressionArgumentsStrategy implements ArgumentsStrategy, BeanFacto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
if (this.evaluationContext == null) {
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory);
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ public class RedisStoreWritingMessageHandler extends AbstractMessageHandler {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void writeToZset(RedisZSet<Object> zset, final Message<?> message) throws Exception {
|
||||
private void writeToZset(RedisZSet<Object> zset, final Message<?> message) {
|
||||
final Object payload = message.getPayload();
|
||||
final BoundZSetOperations<String, Object> ops =
|
||||
(BoundZSetOperations<String, Object>) this.redisTemplate.boundZSetOps(zset.getKey());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -107,7 +107,7 @@ public class RedisChannelMessageStore implements ChannelMessageStore, BeanNameAw
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(this.beanName, "'beanName' must not be null");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.integration.rmi;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.registry.Registry;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.gateway.RequestReplyExchanger;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
@@ -39,7 +38,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class RmiInboundGateway extends MessagingGatewaySupport
|
||||
implements RequestReplyExchanger, InitializingBean {
|
||||
implements RequestReplyExchanger {
|
||||
|
||||
public static final String SERVICE_NAME_PREFIX = "org.springframework.integration.rmiGateway.";
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.sftp.session;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
@@ -394,7 +395,7 @@ public class DefaultSftpSessionFactory implements SessionFactory<LsEntry>, Share
|
||||
}
|
||||
}
|
||||
|
||||
private com.jcraft.jsch.Session initJschSession() throws Exception {
|
||||
private com.jcraft.jsch.Session initJschSession() throws JSchException, IOException {
|
||||
if (this.port <= 0) {
|
||||
this.port = 22;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-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 @@ public class JschProxyFactoryBean extends AbstractFactoryBean<Proxy> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Proxy createInstance() throws Exception {
|
||||
protected Proxy createInstance() {
|
||||
switch (this.type) {
|
||||
case SOCKS5:
|
||||
ProxySOCKS5 socks5proxy = new ProxySOCKS5(this.host, this.port);
|
||||
|
||||
Reference in New Issue
Block a user