Skip to content

fastdfs-client-java 中fastdfs路径中没有文件时,相同路径连续下载2次,第一次返回null;第二次就出错了 #114

Description

@dev-xiexiaogang

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;
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions