You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by re...@apache.org on 2014/10/20 23:58:30 UTC

[1/2] git commit: STREAMS-195 | Added try/catch around ID addition process to ensure that a single malformed ID doesn't derail an entire Stream

Repository: incubator-streams
Updated Branches:
  refs/heads/master 7b01eb48b -> 3a1b818be


STREAMS-195 | Added try/catch around ID addition process to ensure that a single malformed ID doesn't derail an entire Stream


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/d4f60099
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/d4f60099
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/d4f60099

Branch: refs/heads/master
Commit: d4f6009979401d324949b9e7783c5e7ea381299e
Parents: 0a32159
Author: Robert Douglas <rd...@w2ogroup.com>
Authored: Mon Oct 20 09:43:29 2014 -0500
Committer: Robert Douglas <rd...@w2ogroup.com>
Committed: Mon Oct 20 09:43:29 2014 -0500

----------------------------------------------------------------------
 .../provider/TwitterTimelineProvider.java       | 14 ++++---
 .../provider/TwitterTimelineProviderTest.java   | 39 ++++++++++++++++++++
 2 files changed, 48 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d4f60099/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
index e29790e..391c9c1 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
@@ -236,15 +236,19 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable {
      * Using the "info" list that is contained in the configuration, ensure that all
      * account identifiers are converted to IDs (Longs) instead of screenNames (Strings)
      */
-    private void consolidateToIDs() {
+    protected void consolidateToIDs() {
         List<String> screenNames = Lists.newArrayList();
         ids = Lists.newArrayList();
 
         for(String account : config.getInfo()) {
-            if(new Long(account) != null) {
-                ids.add(Long.parseLong(Objects.toString(account, null)));
-            } else {
-                screenNames.add(account);
+            try {
+                if (new Long(account) != null) {
+                    ids.add(Long.parseLong(Objects.toString(account, null)));
+                } else {
+                    screenNames.add(account);
+                }
+            } catch (Exception e) {
+                LOGGER.error("Exception while trying to add ID: {{}}, {}", account, e);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d4f60099/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTest.java b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTest.java
new file mode 100644
index 0000000..0cdede0
--- /dev/null
+++ b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.streams.twitter.provider;
+
+import org.apache.streams.twitter.TwitterUserInformationConfiguration;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class TwitterTimelineProviderTest {
+
+    @Test
+    public void consolidateToIDsTest() {
+        List<String> ids = Arrays.asList("2342342", "", "144523", null);
+
+        TwitterUserInformationConfiguration twitterUserInformationConfiguration = new TwitterUserInformationConfiguration();
+        twitterUserInformationConfiguration.setInfo(ids);
+        TwitterTimelineProvider twitterTimelineProvider = new TwitterTimelineProvider(twitterUserInformationConfiguration);
+
+        twitterTimelineProvider.consolidateToIDs();
+    }
+}


[2/2] git commit: Merge remote-tracking branch 'robdouglas/STREAMS-195'

Posted by re...@apache.org.
Merge remote-tracking branch 'robdouglas/STREAMS-195'


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/3a1b818b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/3a1b818b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/3a1b818b

Branch: refs/heads/master
Commit: 3a1b818bec7c6d5d624cfbf66d555f5ae0819aa1
Parents: 7b01eb4 d4f6009
Author: Ryan Ebanks <ry...@gmail.com>
Authored: Mon Oct 20 16:44:01 2014 -0500
Committer: Ryan Ebanks <ry...@gmail.com>
Committed: Mon Oct 20 16:44:01 2014 -0500

----------------------------------------------------------------------
 .../provider/TwitterTimelineProvider.java       | 14 ++++---
 .../provider/TwitterTimelineProviderTest.java   | 39 ++++++++++++++++++++
 2 files changed, 48 insertions(+), 5 deletions(-)
----------------------------------------------------------------------