-
Notifications
You must be signed in to change notification settings - Fork 904
Open
Description
fastdfs-client-java 中fastdfs路径中没有文件时,相同路径连续下载2次,第一次返回null;第二次就出错了,按超时时间network_timeout配置返回,出现java.net.SocketTimeoutException: Read timed out错误。路径没有文件时和第一次下载一样应该返回null,不应该一直超时。
调用的是 public byte[] download_file1(String file_id) throws IOException, MyException 方法
以下是我测试 代码
@test
public void downF(){
String url = "g1/Wg/wKgAC1ZPK_GAaHPmpk110.xml";
byte[] cupgradeIndexBytes = downloadFile(url);
if(cupgradeIndexBytes == null){
System.out.println("下载为空");
} else {
System.out.println("下载文件大小" + cupgradeIndexBytes.length);
}
byte[] cupgradeIndexBytes1 = downloadFile(url);
if(cupgradeIndexBytes1 == null){
System.out.println("下载为空");
} else {
System.out.println("下载文件大小" + cupgradeIndexBytes1.length);
}
}
public byte[] downloadFile(String fileIdentity) {
try {
String userdir = System.getProperty("user.dir");
System.out.println("--"+userdir);
String config = "..\\config\\fastdfs.properties";
File configFile = new File(config);
ClientGlobal.init(configFile.getAbsolutePath());
if(trackerClient ==null){
trackerClient = new org.csource.fastdfs.TrackerClient();
}
System.out.println("downloadFile:fileIdentity[{}]" + fileIdentity);
TrackerServer trackerServer = this.trackerClient.getTrackerServer();
StorageServer storageServer = this.trackerClient.getStoreStorage(trackerServer);
if (storageServer == null) {
throw new MyException("StorageServer invalid,Storage node crash or disk space not enough!");
} else {
StorageClient1 storage = new StorageClient1(trackerServer, storageServer);
return storage.download_file1(fileIdentity);
}
} catch (Exception var5) {
System.out.println("下载文件失败!" + var5);
var5.printStackTrace();
return null;
}
}
Metadata
Metadata
Assignees
Labels
No labels