Uploaded image for project: 'Sqoop (Retired)'
  1. Sqoop (Retired)
  2. SQOOP-2468 Sqoop2: Make REST interface more resilient to various malformed inputs
  3. SQOOP-2823

Sqoop2: RESTiliency: Remove repetitive try-catch block for accessing POST and PUT request

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.99.7
    • None
    • None

    Description

      I've noticed that we have quite a few repetition of code like this one:

           RoleBean bean = new RoleBean();
      
          try {
            JSONObject json = JSONUtils.parse(ctx.getRequest().getReader());
            bean.restore(json);
          } catch (IOException e) {
            throw new SqoopException(ServerError.SERVER_0003, "Can't read request content", e);
          }
      

      It's relatively a lot of code just because ctx.getRequest() can throw an exception. I would like to propose to create a method in our ctx wrapper to provide the getReader method without any exception, which will simplify the code to:

          bean.restore(JSONUtils.parse(ctx.getReader()));
      

      We'll of course throw an exception on failure - but using our SqoopException mechanism.

      Attachments

        1. SQOOP-2823.patch
          5 kB
          Jarek Jarcec Cecho

        Issue Links

          Activity

            People

              jarcec Jarek Jarcec Cecho
              jarcec Jarek Jarcec Cecho
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: