Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10562

UnsupportedOperationException in DefaultCamelContext#safelyStartRouteServices

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.18.0, 2.18.1
    • 2.18.2, 2.19.0
    • camel-core
    • None
    • Oracle JDK 1.8.0_(<20)

    • Unknown

    Description

      DefaultCamelContext#safelyStartRouteServices the following code is called:

      Collections.sort(startupListeners, new OrderedComparator());
      

      startupListeners is a CopyOnWriteArrayList.

      In the specification of Collections.sort it is stated, that an UnsupportedOperationException is thrown if the collections listiterator doesn't support the set-operation.
      Sadly, the documentation of CopyOnWriteArrayList#listIterator states, that the listiterator doesn't support this operation.
      As expected in this szenario, the UnsupportedOperationException is thrown during startup of the camel context if an Oracle JDK 1.8.0 with patchlevel lower than 20 is used.
      In 1.8.0_20 the operation Collections#sort(List,Comparator) is rewritten to delegate to List#sort(Comparator) so it doesn't matter anymore if the lists listIterator supports the set-operation.

      The issue can trivially been fixed by replacing the line by

      startupListeners.sort(new OrderedComparator());
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            davsclaus Claus Ibsen
            sschulze Stefan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment