Uploaded image for project: 'Sentry'
  1. Sentry
  2. SENTRY-2469

Fix bugs in RoleServlet

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: None
    • Component/s: Sentry
    • Labels:
      None

      Description

      Fredy found several issues in RoleServlet.java. We need to fix it.

      1. `RoleServlet` at L62 needs to use either `try` resource or put it in the `finally` block to avoid resource leak
      2. `if (conf.getBoolean(ServerConfig.SENTRY_WEB_ENABLE, ServerConfig.SENTRY_WEB_ENABLE_DEFAULT))` may return an NPE if `conf.getBoolean` returns a `null` `Boolean` (not the primitive type)
      3. `RoleServlet` at L45, use `Preconditions.checkNotNull` or `Objects.requreNonNull` instead of `assert`
      4. `RoleServlet` at L55: `String json = new Gson().toJson(roleMap);`, it's better to reuse the `Gson` instance.

        Attachments

        1. SENTRY-2469.001.patch
          0.7 kB
          zhaohongtao

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              LinaAtAustin Na Li
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: