Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E3AC519429 for ; Tue, 12 Apr 2016 10:36:25 +0000 (UTC) Received: (qmail 64576 invoked by uid 500); 12 Apr 2016 10:36:25 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 64529 invoked by uid 500); 12 Apr 2016 10:36:25 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 64513 invoked by uid 99); 12 Apr 2016 10:36:25 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Apr 2016 10:36:25 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 75CAF2C1F5C for ; Tue, 12 Apr 2016 10:36:25 +0000 (UTC) Date: Tue, 12 Apr 2016 10:36:25 +0000 (UTC) From: "Claus Ibsen (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CAMEL-9850) Twitter: truncation has no effect MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-9850?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Claus Ibsen updated CAMEL-9850: ------------------------------- Fix Version/s: 2.18.0 > Twitter: truncation has no effect > --------------------------------- > > Key: CAMEL-9850 > URL: https://issues.apache.org/jira/browse/CAMEL-9850 > Project: Camel > Issue Type: Bug > Components: camel-twitter > Affects Versions: 2.17.0 > Reporter: martin scharm > Fix For: 2.18.0 > > > h3. Problem > The current version of camel-twitter implements a truncation that does not have any effect: > [UserProducer.java#L66|https://github.com/apache/camel/blob/83383c6318b1861d82d447165714f976e62229ab/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/UserProducer.java#L66] > {code:java} > if (status.length() > 160) { > log.warn("Message is longer than 160 characters. Message will be truncated!"); > status = status.substring(0, 160); > } > {code} > 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. > h3. Proposals > To fix this issue I prepared three proposals: > h4. Remove Truncation > As the truncation has no effect anyway it could simply be deleted. See my [commit b96035b on github|https://github.com/binfalse/camel/commit/b96035b239974e3ddf4cb1c9a84258e11b9a1433]. > h4. Update Truncation > Update the current code to truncate to 140 chars. See my [commit 83b3f30 on github|https://github.com/binfalse/camel/commit/83b3f30c3ff993c50a250fd1085d7830c6570b62]. > h4. 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|https://github.com/binfalse/camel/commit/83b3f30c3ff993c50a250fd1085d7830c6570b62] I implemented optional truncation in my [commit bbbff05 on github|https://github.com/binfalse/camel/commit/bbbff051f3f982711e91ea60fb86b9218b567d63]. > 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.: > {code} > twitter://timeline/user?consumerKey=%s&...&truncate=true > {code} > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332)