Skip to content

Add a PartialUpdateException [INT-3593] #7534

@spring-operator

Description

@spring-operator

Gary Russell opened INT-3593 and commented

Certain message handlers, e.g. (S)FTP outbound gateways, can perform multiple operations from a single message (e.g. MPUT).

If an exception occurs during this process, it is possible for a partial update to have occurred.

It would be useful for logging/recovery, if the user can determine the point at which the exception occurred.

Something like...

/**
 * A {@link MessageHandlingException} thrown when a non-transactional message handler is
 * performing multiple updates from a single message, e.g. an FTP 'mput' operation.
 *
 * @author Gary Russell
 * @since 4.2
 *
 */
@SuppressWarnings("serial")
public class PartialUpdateException extends MessageHandlingException {

	private final Collection<?> partialResults;

	private final Collection<?> derivedInput;

	public PartialUpdateException(Message<?> message, String description, Throwable cause) {
		this(message, description, cause, null, null);
	}

	public PartialUpdateException(Message<?> message, String description) {
		this(message, description, null, null, null);
	}

	public PartialUpdateException(Message<?> failedMessage, Throwable cause) {
		this(failedMessage, null, cause, null, null);
	}

	public PartialUpdateException(Message<?> failedMessage) {
		this(failedMessage, null, null, null, null);
	}

	/**
	 *
	 * @param message the message.
	 * @param description the description.
	 * @param cause the cause.
	 * @param partialResults The subset of multiple updates that were successful before the cause occurred.
	 * @param derivedInput The collection (usually derived from the message) of input data; e.g. a filtered
	 * list of local files being sent to FTP using {@code mput}.
	 */
	public <R, I> PartialUpdateException(Message<?> message, String description, Throwable cause,
			Collection<R> partialResults, Collection<I> derivedInput) {
		super(message, description, cause);
		this.partialResults = partialResults;
		this.derivedInput = derivedInput;
	}

	@SuppressWarnings("unchecked")
	public <T> Collection<T> getPartialResults(Class<T> clazz) {
		return (Collection<T>) this.partialResults;
	}

	@SuppressWarnings("unchecked")
	public <T> Collection<T> getDerivedInput(Class<T> clazz) {
		return (Collection<T>) this.derivedInput;
	}

}

Unfortunately, subclasses of Throwable can't be generic so the casts are required.

Add code to the AbstractRemoteFileOutboundGateway to throw this exception from mput and mget operations.


Referenced from: pull request #1511

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions