Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-4675

Throw AopInvocationException on advice returning null for primitive type

    Details

    • Last commented by a User:
      false

      Description

      Could we please throw an exception in a proxy if the return value is null and should be a primitive type?

      It is extremely hard to debug at present if you happen to intercept a method that returns a primitive type, and the proxy then returns null. The stack trace has no useful line numbers in it (since it comes from the $Proxy) and there is no way to know what you have done wrong. Wouldn't it be worth the cost of a check for null if the type is primitive (e.g. in JdkDynamicAopProxy after the call to invocation.proceed())? Probably it would be no more expensive than the existing special case there already for detecting "return this".

        Attachments

          Activity

            People

            • Assignee:
              pwebb Phil Webb
              Reporter:
              david_syer Dave Syer
              Last updater:
              Chris Beams
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 4 days ago