Skip to content

Commit 0a01803

Browse files
author
吴炳亨
authored
Merge pull request #288 from NigelWu95/dev
Dev
2 parents aeaf17e + 71175e7 commit 0a01803

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.qiniu</groupId>
88
<artifactId>qsuits</artifactId>
9-
<version>8.3.10</version>
9+
<version>8.3.11</version>
1010
<name>qsuits</name>
1111
<description>qiniu-suits is a efficient tools for qiniu api implemented by java8.</description>
1212
<url>https://github.com/NigelWu95/qiniu-suits-java</url>

src/main/java/com/qiniu/entry/CommonParams.java

+2
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,8 @@ private void setSavePath() throws IOException {
12491249
savePath = "local".equals(source) ? (path.endsWith(FileUtils.pathSeparator) ?
12501250
path.substring(0, path.length() - 1) : path) + "-result" : bucket;
12511251
savePath = savePath.substring(savePath.lastIndexOf(FileUtils.pathSeparator) + 1);
1252+
} else {
1253+
savePath = FileUtils.convertToRealPath(savePath);
12521254
}
12531255
if (CloudApiUtils.isFileSource(source) && FileUtils.convertToRealPath(path).equals(FileUtils.convertToRealPath(savePath))) {
12541256
throw new IOException(String.format("the save-path \"%s\" can not be same as path.", savePath));

src/main/java/com/qiniu/process/filtration/FilterProcess.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public FilterProcess<T> clone() throws CloneNotSupportedException {
125125
@Override
126126
public void changeSaveOrder(String order) throws IOException {
127127
try {
128-
this.fileSaveMapper.changePrefixAndSuffix(processName, order);
128+
if (nextProcessor != null) nextProcessor.changeSaveOrder(order);
129+
else fileSaveMapper.changePrefixAndSuffix(processName, order);
129130
} catch (NullPointerException e) {
130131
throw new IOException("instance without savePath can not call changeSaveOrder method.");
131132
}
@@ -148,7 +149,7 @@ public String processLine(T line) throws IOException {
148149
} else if (filter == null) { // 如果是关闭了那么 filter 应该为 null
149150
throw new IOException("input is empty or the processor may be already closed.");
150151
} else {
151-
throw new IOException("instance without savePath can not call this batch process method.");
152+
throw new IOException(e.getMessage());
152153
}
153154
} catch (IOException e) {
154155
throw e;
@@ -182,8 +183,22 @@ public void processLine(List<T> list) throws IOException {
182183
// 默认在不进行进一步处理的情况下直接保存结果,如果需要进一步处理则不保存过滤的结果。
183184
if (nextProcessor == null) {
184185
List<String> writeList = typeConverter.convertToVList(filterList);
185-
if (writeList.size() > 0) fileSaveMapper.writeSuccess(String.join("\n", writeList), false);
186-
if (typeConverter.errorSize() > 0) fileSaveMapper.writeError(typeConverter.errorLines(), false);
186+
try {
187+
if (writeList.size() > 0) fileSaveMapper.writeSuccess(String.join("\n", writeList), false);
188+
if (typeConverter.errorSize() > 0) fileSaveMapper.writeError(typeConverter.errorLines(), false);
189+
} catch (NullPointerException e) {
190+
if (canceled) {
191+
// // nothing to do
192+
} else if (filter == null) { // 如果是关闭了那么 filter 应该为 null
193+
throw new IOException("input is empty or the processor may be already closed.");
194+
} else {
195+
throw new IOException("instance without savePath can not call this batch process method.");
196+
}
197+
} catch (IOException e) {
198+
throw e;
199+
} catch (Exception e) {
200+
throw new IOException(e.getMessage());
201+
}
187202
} else {
188203
nextProcessor.processLine(filterList);
189204
}
@@ -194,6 +209,7 @@ public void closeResource() {
194209
filter = null;
195210
if (nextProcessor != null) nextProcessor.closeResource();
196211
savePath = null;
212+
saveIndex = null;
197213
if (fileSaveMapper != null) fileSaveMapper.closeWriters();
198214
fileSaveMapper = null;
199215
typeConverter = null;

src/test/java/com/qiniu/process/aws/PrivateUrlTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void testProcessLine() throws Exception {
2020
String bucket = "7zmz4b";
2121
String region = "cn-east-1";
2222
String endpoint = "http://s3-cn-east-1.qiniucs.com";
23-
PrivateUrl privateUrl = new PrivateUrl(accessKeyId, accessKeySecret, bucket, endpoint, region, 3600000, null, "~/Downloads");
23+
PrivateUrl privateUrl = new PrivateUrl(accessKeyId, accessKeySecret, bucket, endpoint, region, false, 3600000, null, "~/Downloads");
2424
String result = privateUrl.singleResult(new HashMap<String, String>(){{
2525
put("key", "0000021");
2626
}});

src/test/java/com/qiniu/process/qiniu/CdnUrlProcessTest.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.qiniu.process.qiniu;
22

33
import com.qiniu.config.PropertiesFile;
4+
import com.qiniu.storage.Configuration;
45
import org.junit.Test;
56

67
import java.io.IOException;
@@ -17,7 +18,7 @@ public void testSingleRefresh() throws IOException {
1718
PropertiesFile propertiesFile = new PropertiesFile("resources/.application.properties");
1819
String accessKey = propertiesFile.getValue("ak");
1920
String secretKey = propertiesFile.getValue("sk");
20-
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, null, null, "url", false, false);
21+
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, new Configuration(), null, null, "url", false, false);
2122
String result = cdnUrlProcess.singleResult(new HashMap<String, String>(){{
2223
put("url", "http://xxx.cn/upload/24790f63-0936-44c4-8695-a6d6b1dd8d91.jpg");
2324
}});
@@ -30,7 +31,7 @@ public void testBatchRefresh() throws IOException {
3031
PropertiesFile propertiesFile = new PropertiesFile("resources/.application.properties");
3132
String accessKey = propertiesFile.getValue("ak");
3233
String secretKey = propertiesFile.getValue("sk");
33-
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, null, null, "url", true, false,
34+
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, new Configuration(), null, null, "url", true, false,
3435
"/Users/wubingheng/Downloads/refresh");
3536
List<Map<String, String>> list = new ArrayList<>();
3637
// list.add(new HashMap<String, String>(){{
@@ -64,7 +65,7 @@ public void testBatchPrefetch() throws IOException {
6465
PropertiesFile propertiesFile = new PropertiesFile("resources/.application.properties");
6566
String accessKey = propertiesFile.getValue("ak");
6667
String secretKey = propertiesFile.getValue("sk");
67-
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, null, null, "url", false, true,
68+
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, new Configuration(), null, null, "url", false, true,
6869
"/Users/wubingheng/Downloads/refresh");
6970
List<Map<String, String>> list = new ArrayList<>();
7071
list.add(new HashMap<String, String>(){{
@@ -85,7 +86,7 @@ public void testClone() throws IOException, CloneNotSupportedException {
8586
PropertiesFile propertiesFile = new PropertiesFile("resources/.application.properties");
8687
String accessKey = propertiesFile.getValue("ak");
8788
String secretKey = propertiesFile.getValue("sk");
88-
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, null, null, "url", false, true,
89+
CdnUrlProcess cdnUrlProcess = new CdnUrlProcess(accessKey, secretKey, new Configuration(), null, null, "url", false, true,
8990
"/Users/wubingheng/Downloads/refresh");
9091
System.out.println(cdnUrlProcess);
9192
CdnUrlProcess cdnUrlProcess1 = cdnUrlProcess.clone();

src/test/java/com/qiniu/process/tencent/PrivateUrlTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void testProcessLine() throws Exception {
1919
String accessKeySecret = propertiesFile.getValue("ten-secret");
2020
String bucket = propertiesFile.getValue("bucket");
2121
String region = "ap-shanghai";
22-
PrivateUrl privateUrl = new PrivateUrl(accessKeyId, accessKeySecret, bucket, region, 3600, null, "~/Downloads");
22+
PrivateUrl privateUrl = new PrivateUrl(accessKeyId, accessKeySecret, bucket, region, false, 3600, null, "~/Downloads");
2323
String result = privateUrl.singleResult(new HashMap<String, String>(){{
2424
put("key", "24790f63-0936-44c4-8695-a6d6b1dd8d91.jpg");
2525
}});

version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=8.3.10
1+
version=8.3.11

0 commit comments

Comments
 (0)