Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7867

asType(Collection col, Class clazz) ingnores exceptions in clazz constructor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8, 3.x, 2.5.0-beta-1
    • 4.0.0-beta-1, 3.0.9
    • groovy-runtime
    • None
    • no matter

    Description

      Method ignores exception in clazz constructor, and if any - throws exception later, when try find constructor with args matches collection items.

      public static <T> T asType(Collection col, Class<T> clazz) in DefaultGroovyMethods.java, line 10623:

      DefaultGroovyMethods.java
              Object[] args = {col};
              try {
                  return (T) InvokerHelper.invokeConstructorOf(clazz, args);
              } catch (Exception e) {
                  // ignore, the constructor that takes a Collection as an argument may not exist
              }
      

      In my opinion, should ignore only if such constroctor not found

      Attachments

        Activity

          People

            Unassigned Unassigned
            DameNoSupaplex Pavel Novichenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h