• R/O
  • SSH
  • HTTPS

nt-manager: Commit


Commit MetaInfo

Revision172 (tree)
Time2011-08-24 03:44:35
Authorspark_xp

Log Message

Search API利用中にConcurrentModificationExceptionがでていた問題を修正

Change Summary

Incremental Difference

--- NishioTweetManager/trunk/src/twitter/manage/TweetSearchStream.java (revision 171)
+++ NishioTweetManager/trunk/src/twitter/manage/TweetSearchStream.java (revision 172)
@@ -105,12 +105,15 @@
105105 */
106106 @Override
107107 public void onStatus(Status status) {
108- for(String word : listeners.keySet()) {
109- if( status.getText().contains( word.toString() ) ) {
110- TweetStreamingListener listener = listeners.get(word);
111- listener.update(status);
112- //最終更新id
113- lastUpdate.put(word, status.getId());
108+ Set<String> keys = listeners.keySet();
109+ synchronized (listeners) {
110+ for(String word : keys) {
111+ if( status.getText().contains( word.toString() ) ) {
112+ TweetStreamingListener listener = listeners.get(word);
113+ listener.update(status);
114+ //最終更新id
115+ lastUpdate.put(word, status.getId());
116+ }
114117 }
115118 }
116119 }
@@ -143,13 +146,12 @@
143146 } catch (TwitterException e) {
144147 e.printStackTrace();
145148 }
146- for(;;) {
149+ for(; statusStream != null; ) {
147150 try {
148- if( statusStream != null ) {
149- statusStream.next(this);
150- }
151- } catch (TwitterException e) {
151+ statusStream.next(this);
152+ }catch(Exception e) {
152153 e.printStackTrace();
154+ break;
153155 }
154156 }
155157 }
Show on old repository browser