Merge remote-tracking branch 'upstream/master' into 4.0.0-WIP
Conflicts: spring-integration-core/src/main/java/org/springframework/integration/channel/registry/ChannelRegistry.java spring-integration-core/src/main/java/org/springframework/integration/channel/registry/LocalChannelRegistry.java spring-integration-core/src/main/java/org/springframework/integration/mapping/AbstractHeaderMapper.java spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonMessageParser.java spring-integration-core/src/test/java/org/springframework/integration/channel/registry/LocalChannelRegistryTests.java spring-integration-core/src/test/java/org/springframework/integration/handler/ServiceActivatorDefaultFrameworkMethodTests.java spring-integration-jmx/src/test/java/org/springframework/integration/jmx/ServiceActivatorDefaultFrameworkMethodTests.java spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/OperationInvokingOutboundGatewayTests.java Resolved.
This commit is contained in:
@@ -16,11 +16,15 @@
|
||||
|
||||
package org.springframework.integration.file;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -329,12 +333,12 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
private File handleFileMessage(final File sourceFile, File tempFile, final File resultFile) throws IOException {
|
||||
if (FileExistsMode.APPEND.equals(this.fileExistsMode)){
|
||||
File fileToWriteTo = this.determineFileToWrite(resultFile, tempFile);
|
||||
final FileOutputStream fos = new FileOutputStream(fileToWriteTo, true);
|
||||
final FileInputStream fis = new FileInputStream(sourceFile);
|
||||
final BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileToWriteTo, true));
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(sourceFile));
|
||||
WhileLockedProcessor whileLockedProcessor = new WhileLockedProcessor(this.lockRegistry, fileToWriteTo.getAbsolutePath()){
|
||||
@Override
|
||||
protected void whileLocked() throws IOException {
|
||||
FileCopyUtils.copy(fis, fos);
|
||||
FileCopyUtils.copy(bis, bos);
|
||||
}
|
||||
};
|
||||
whileLockedProcessor.doWhileLocked();
|
||||
@@ -362,11 +366,11 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
|
||||
final boolean append = FileExistsMode.APPEND.equals(this.fileExistsMode);
|
||||
|
||||
final FileOutputStream fos = new FileOutputStream(fileToWriteTo, append);
|
||||
final BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileToWriteTo, append));
|
||||
WhileLockedProcessor whileLockedProcessor = new WhileLockedProcessor(this.lockRegistry, fileToWriteTo.getAbsolutePath()){
|
||||
@Override
|
||||
protected void whileLocked() throws IOException {
|
||||
FileCopyUtils.copy(bytes, fos);
|
||||
FileCopyUtils.copy(bytes, bos);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -380,7 +384,7 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
|
||||
final boolean append = FileExistsMode.APPEND.equals(this.fileExistsMode);
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(fileToWriteTo, append), this.charset);
|
||||
final Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileToWriteTo, append), this.charset));
|
||||
WhileLockedProcessor whileLockedProcessor = new WhileLockedProcessor(this.lockRegistry, fileToWriteTo.getAbsolutePath()){
|
||||
@Override
|
||||
protected void whileLocked() throws IOException {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.file.remote.gateway;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -521,9 +522,9 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
|
||||
if (!localFile.exists()) {
|
||||
String tempFileName = localFile.getAbsolutePath() + this.temporaryFileSuffix;
|
||||
File tempFile = new File(tempFileName);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
|
||||
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(tempFile));
|
||||
try {
|
||||
session.read(remoteFilePath, fileOutputStream);
|
||||
session.read(remoteFilePath, outputStream);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof RuntimeException){
|
||||
@@ -535,7 +536,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
catch (Exception ignored2) {
|
||||
//Ignore it
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package org.springframework.integration.file.remote.synchronizer;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -202,9 +204,9 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
|
||||
if (!localFile.exists()) {
|
||||
String tempFileName = localFile.getAbsolutePath() + this.temporaryFileSuffix;
|
||||
File tempFile = new File(tempFileName);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
|
||||
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(tempFile));
|
||||
try {
|
||||
session.read(remoteFilePath, fileOutputStream);
|
||||
session.read(remoteFilePath, outputStream);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof RuntimeException){
|
||||
@@ -216,7 +218,7 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
catch (Exception ignored2) {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 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,9 +16,11 @@
|
||||
|
||||
package org.springframework.integration.file.transformer;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -26,8 +28,9 @@ import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* A payload transformer that copies a File's contents to a String.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class FileToStringTransformer extends AbstractFilePayloadTransformer<String> {
|
||||
|
||||
@@ -45,7 +48,7 @@ public class FileToStringTransformer extends AbstractFilePayloadTransformer<Stri
|
||||
|
||||
@Override
|
||||
protected final String transformFile(File file) throws Exception {
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(file), this.charset);
|
||||
Reader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), this.charset));
|
||||
return FileCopyUtils.copyToString(reader);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user