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

Twitter: truncation has no effect

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.17.0
    • Fix Version/s: 2.17.1, 2.18.0
    • Component/s: camel-twitter
    • Labels:
      None
    • Patch Info:
      Patch Available
    • Estimated Complexity:
      Unknown

      Description

      Problem

      The current version of camel-twitter implements a truncation that does not have any effect:
      UserProducer.java#L66

      if (status.length() > 160) {
          log.warn("Message is longer than 160 characters. Message will be truncated!");
          status = status.substring(0, 160);
      }
      

      Status updates were truncated to 160 chars if they were longer.

      However, the twitter limit is 140 chars. Updates with a length of 141-160 will not be truncated and fail; updates with a length of more than 160 will be truncated to 160 chars and still fail.
      Moreover, there are longer messages that are nevertheless compliant with the 140 char limit. See for example URLs: every URL is shortened using twitter's t.co shortener. Thus, even very long URLs occupy just a handful characters and the character counting, as used in camel-twitter, fails.

      Proposals

      To fix this issue I prepared three proposals:

      Remove Truncation

      As the truncation has no effect anyway it could simply be deleted. See my commit b96035b on github.

      Update Truncation

      Update the current code to truncate to 140 chars. See my commit 83b3f30 on github.

      Introduce an optional Truncation

      As explained above, there are valid messages with more than 140 characters, eg. containing long URLs (see above). Using the previous solution it would not be possible to tweet them.
      Thus, based on commit 83b3f30 I implemented optional truncation in my commit bbbff05 on github.
      That way, the client can decide whether messages should be truncated or not. There is a new flag truncate that can be used what creating an endpoint, eg.:

      twitter://timeline/user?consumerKey=%s&...&truncate=true
      

      However, if deciding for truncate=false the client should be aware that updating twitter may fail raising a twitter4j.TwitterException.

      I nevertheless set the default value to false, as this best reflects the previous behaviour and will not break other code.

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              binfalse martin scharm

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment