happyfish100 / happyfish100/fastdfs-client-java
fastdfs-client-java 中fastdfs路径中没有文件时,相同路径连续下载2次,第一次返回null;第二次就出错了
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 891
- PR merge metrics
- No merged PRs in 30d
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;
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at StorageClient1.download_file1(String file_id) and reproduce the provided test with a nonexistent FastDFS path, calling it twice. Compare the first null result with the second call's read timeout and inspect the client connection or response handling between calls. Done means repeated missing-file downloads return null without waiting for network_timeout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100