Skip to content

GET processing in RestServlet.java is no good from a performance view point. #86

@araobp

Description

@araobp
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    Request.Method method;
    try {
      method = Request.Method.valueOf(req.getMethod().toUpperCase());
    } catch (IllegalArgumentException e) {
      super.service(req, resp);
      return;
    }

    do {
      if (!method.equals(Request.Method.GET)) {
        break;
      }

      String root = (String) this.getServletContext().getAttribute("resource.root");
      if (root == null) {
        break;
      }

      String path = root + req.getPathInfo();
      this.logger.debug("Trying to read \"{}\".", path);

      InputStream in = null;
      try {
        in = new FileInputStream(path);  <=== REST GET also runs this.
      } catch (FileNotFoundException e) {
        break;
      }

      OutputStream out = resp.getOutputStream();
      IOUtils.copy(in, out);
      try {
        in.close();
      } catch (IOException e) {
        // just ignore.
      }
      return;
    } while (false);

    doRequestToComponent(req, resp, method);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions