Uploaded image for project: 'Webservices REST Module'
  1. Webservices REST Module
  2. RESTWS-471

A resource implementing Listable without Searchable fails in MainResourceController

    Details

    • Type: Bug
    • Status: Closed
    • Priority: TBD
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.7
    • Labels:
      None
    • Complexity:
      Low

      Description

      Definitely related to RESTWS-434.

      MainResourceController.get currently unconditionally casts the resource to Searchable (line 154) but then doesn't use it as a Searchable until it's found some search parameters - at which case it uses instanceof to check that it's Searchable, and casts again.

      This means that a resource which implements Listable but not Searchable fails with a ClassCastException. The workaround is to implement Listable but throw an UnsupportedOperationException if search is ever called.

      The fix would be to just change the type of res to Object:

      Object res = restService.getResourceByName(buildResourceName(resource));

      Everything that uses it checks with instanceof and then casts anyway, as far as I can see on a quick inspection.

        Attachments

          Activity

            People

            • Assignee:
              jonskeet Jon Skeet [X] (Inactive)
              Reporter:
              jonskeet Jon Skeet [X] (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: