Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.xutils.ex.FileLockedException: 报异常 #730

Open
zjianflys opened this issue Dec 24, 2021 · 1 comment
Open

org.xutils.ex.FileLockedException: 报异常 #730

zjianflys opened this issue Dec 24, 2021 · 1 comment

Comments

@zjianflys
Copy link

`package com.xz.comm.net;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.StringUtils;
import com.xz.comm.constant.ResponseContants;
import com.xz.comm.utils.StringExtUtils;

import org.xutils.http.app.ResponseParser;
import org.xutils.http.request.UriRequest;

import java.io.File;
import java.lang.reflect.Type;

/**

  • 添加在params对象的注解参数中.

  • 如果泛型为 byte[] 或 InputStream, 可以方便的转换protobuf对象.
    */
    public class FileResponseParse implements ResponseParser {

    /**

    • 自定义请求
      */
      private String sessionid = "";

    /**

    • 转换result为resultType类型的对象
    • @param resultType 返回值类型(可能带有泛型信息)
    • @param resultClass 返回值类型
    • @param result 网络返回数据(支持String, byte[], JSONObject, JSONArray, InputStream)
    • @return 请求结果, 类型为resultType
      */
      @OverRide
      public Object parse(Type resultType, Class<?> resultClass, File result) throws Throwable {
      FileResponseEntity fileResponseEntity = new FileResponseEntity();
      fileResponseEntity.setSessionid(sessionid);
      if (result != null) {
      fileResponseEntity.setFile(result);
      }
      return fileResponseEntity;
      }

    /**

    • 检查请求参数等处理
      */
      @OverRide
      public void beforeRequest(UriRequest request) throws Throwable {

    }

    /**

    • 检查请求相应头等处理
      */
      @OverRide
      public void afterRequest(UriRequest request) throws Throwable {
      try {
      sessionid = request.getResponseHeader("sessionid");
      } catch (Exception e) {
      e.printStackTrace();
      }
      }
      }
      `
      这点这个泛型为FIle.

报错信息:
2021-12-24 15:55:28.862 27666-27666/com.x.vi W/System.err: org.xutils.ex.FileLockedException: /storage/emulated/0/Android/data/com.x.vi/cache/xUtils_cache/ab750342e0211701ba4e4263281e0d64 2021-12-24 15:55:28.863 27666-27666/com.x.vi W/System.err: at org.xutils.cache.LruDiskCache.commitDiskCacheFile(LruDiskCache.java:226) 2021-12-24 15:55:28.863 27666-27666/com.x.vi W/System.err: at org.xutils.cache.DiskCacheFile.commit(DiskCacheFile.java:31) 2021-12-24 15:55:28.863 27666-27666/com.x.vi W/System.err: at org.xutils.http.loader.FileLoader.load(FileLoader.java:151) 2021-12-24 15:55:28.863 27666-27666/com.x.vi W/System.err: at org.xutils.http.loader.FileLoader.load(FileLoader.java:242) 2021-12-24 15:55:28.864 27666-27666/com.x.vi W/System.err: at org.xutils.http.loader.FileLoader.load(FileLoader.java:41) 2021-12-24 15:55:28.864 27666-27666/com.x.vi W/System.err: at org.xutils.http.loader.ObjectLoader.load(ObjectLoader.java:90) 2021-12-24 15:55:28.864 27666-27666/com.x.vi W/System.err: at org.xutils.http.request.UriRequest.loadResult(UriRequest.java:79) 2021-12-24 15:55:28.864 27666-27666/com.x.vi W/System.err: at org.xutils.http.request.HttpRequest.loadResult(HttpRequest.java:296) 2021-12-24 15:55:28.864 27666-27666/com.x.vi W/System.err: at org.xutils.http.HttpTask$RequestWorker.request(HttpTask.java:601) 2021-12-24 15:55:28.865 27666-27666/com.x.vi W/System.err: at org.xutils.http.HttpTask.doBackground(HttpTask.java:298) 2021-12-24 15:55:28.865 27666-27666/com.x.vi W/System.err: at org.xutils.common.task.TaskProxy$1.run(TaskProxy.java:73) 2021-12-24 15:55:28.865 27666-27666/com.x.vi W/System.err: at org.xutils.common.task.PriorityRunnable.run(PriorityRunnable.java:21) 2021-12-24 15:55:28.865 27666-27666/com.x.vi W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 2021-12-24 15:55:28.865 27666-27666/com.x.vi W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 2021-12-24 15:55:28.866 27666-27666/com.x.vi W/System.err: at java.lang.Thread.run(Thread.java:919)

@zjianflys
Copy link
Author

public class FileResponseParse implements ResponseParser<File> {
方法是这样的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant