Skip to content

Commit

Permalink
[FLINK-11867][datastream] Fixed preconditions for filePath's value
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Goong authored and dawidwys committed Mar 11, 2019
1 parent dbc6b18 commit 2995ca1
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.apache.flink.streaming.api.transformations.StreamTransformation;
import org.apache.flink.util.Preconditions;
import org.apache.flink.util.SplittableIterator;
import org.apache.flink.util.StringUtils;

import com.esotericsoftware.kryo.Serializer;

Expand Down Expand Up @@ -958,8 +959,7 @@ public DataStreamSource<String> readTextFile(String filePath) {
* @return The data stream that represents the data read from the given file as text lines
*/
public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
Preconditions.checkNotNull(filePath, "The file path must not be null.");
Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(filePath), "The file path must not be null or blank.");

TextInputFormat format = new TextInputFormat(new Path(filePath));
format.setFilesFilter(FilePathFilter.createDefaultFilter());
Expand Down Expand Up @@ -1156,8 +1156,7 @@ public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
TypeInformation<OUT> typeInformation) {

Preconditions.checkNotNull(inputFormat, "InputFormat must not be null.");
Preconditions.checkNotNull(filePath, "The file path must not be null.");
Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(filePath), "The file path must not be null or blank.");

inputFormat.setFilePath(filePath);
return createFileInput(inputFormat, typeInformation, "Custom File Source", watchType, interval);
Expand Down

0 comments on commit 2995ca1

Please sign in to comment.