Griffon
  1. Griffon
  2. GRIFFON-288

Exception when using ShutdownHandler using a Map as ShutdownHandler

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.2-beta-2
    • Fix Version/s: 0.9.2-beta-3
    • Component/s: rt
    • Labels:
      None
    • Environment:
      All
    • Number of attachments :
      0

      Description

      When you add a ShutdownHandler as a ConvertedMap (see code below)

      class SampleController {
      ...
      ShutdownHandler shutdownHandler = [
                canShutdown: {app -> return view.builder.optionPane().showConfirmDialog(app.windowManager.windows[0], "Do you really want to exit?", "Exit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION },
                onShutdown: {app -> }
        ] as ShutdownHandler
      
        def onReadyEnd = { GriffonApplication app -> app.addShutdownHandler(shutdownHandler) }
      ...
      }
      

      and you will cancel the closing (clicking 'No' in this example) you get the following Exception:

      java.lang.UnsupportedOperationException
      	at $Proxy4.toString(Unknown Source)
      	at griffon.core.BaseGriffonApplication.canShutdown(BaseGriffonApplication.groovy:141)
      	at griffon.core.GriffonApplication$canShutdown.callCurrent(Unknown Source)
      	at griffon.core.BaseGriffonApplication.shutdown(BaseGriffonApplication.groovy:153)
      	at griffon.core.GriffonApplication$shutdown.call(Unknown Source)
      	at griffon.swing.SwingApplication.shutdown(SwingApplication.groovy:65)
      	at griffon.swing.WindowManager$WindowHelper.windowClosing(WindowManager.java:169)
      

      This is because a Proxy does not correctly support toString(), which is invoked on logging a debug message.
      I solved this by catching the exception and logging a static message.

        Activity

        Hide
        Alexander Klein added a comment -

        Pushed the fix

        Show
        Alexander Klein added a comment - Pushed the fix

          People

          • Assignee:
            Alexander Klein
            Reporter:
            Alexander Klein
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10 minutes
              10m
              Remaining:
              Remaining Estimate - 10 minutes
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified