Wicket
  1. Wicket
  2. WICKET-3649

ClassCastException when AbstractResource writes in response of some type other than WebResponse

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5-RC3
    • Fix Version/s: 1.5-RC5
    • Component/s: wicket
    • Labels:
      None

      Description

      Some times is usefull to write the resource in ByteArrayResponse to access the response bytes latter. An use case is ThumbnailImageResource accessing the wrapped resource image to first resize it and than write in response.

      1. WICKET-3649.patch
        7 kB
        Pedro Santos
      2. WICKET-3649-refactoring-fix-test.patch
        9 kB
        Pedro Santos

        Issue Links

          Activity

          Hide
          Pedro Santos added a comment - - edited

          Same fix moving header setup code to ResourceResponse and test case preventing the bug.

          IMO AbtratctResource is just an API to request handlers objects and all response setup code makes more sense inside ResourceResponse. The attached patch do not move cache headers setup to it since this change would involve API break.

          Show
          Pedro Santos added a comment - - edited Same fix moving header setup code to ResourceResponse and test case preventing the bug. IMO AbtratctResource is just an API to request handlers objects and all response setup code makes more sense inside ResourceResponse. The attached patch do not move cache headers setup to it since this change would involve API break.
          Hide
          Martin Grigorov added a comment -

          Running the new test in Maven fails with:

          Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.071 sec <<< FAILURE!
          testThumbnailImageResource(org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResourceTest) Time elapsed: 1.067 sec <<< ERROR!
          java.lang.IllegalArgumentException: Unknown image type 0
          at java.awt.image.BufferedImage.<init>(BufferedImage.java:492)
          at org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResource.getScaledImageInstance(ThumbnailImageResource.java:158)
          at org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResource.getImageData(ThumbnailImageResource.java:91)
          at org.apache.wicket.request.resource.DynamicImageResource$1.writeData(DynamicImageResource.java:156)
          at org.apache.wicket.request.resource.AbstractResource.respond(AbstractResource.java:524)
          at org.apache.wicket.request.handler.resource.ResourceRequestHandler.respond(ResourceRequestHandler.java:77)
          ....

          In Eclipse it passes.

          Show
          Martin Grigorov added a comment - Running the new test in Maven fails with: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.071 sec <<< FAILURE! testThumbnailImageResource(org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResourceTest) Time elapsed: 1.067 sec <<< ERROR! java.lang.IllegalArgumentException: Unknown image type 0 at java.awt.image.BufferedImage.<init>(BufferedImage.java:492) at org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResource.getScaledImageInstance(ThumbnailImageResource.java:158) at org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResource.getImageData(ThumbnailImageResource.java:91) at org.apache.wicket.request.resource.DynamicImageResource$1.writeData(DynamicImageResource.java:156) at org.apache.wicket.request.resource.AbstractResource.respond(AbstractResource.java:524) at org.apache.wicket.request.handler.resource.ResourceRequestHandler.respond(ResourceRequestHandler.java:77) .... In Eclipse it passes.

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Pedro Santos
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development