Feb 11, 2017 13:11
yup
Feb 11, 2017 13:11
can you edit your answer accordingly for that next boolean as well just to make it complete?
Feb 11, 2017 13:10
but your suggestions are good
Feb 11, 2017 13:10
yeah you are right in terms of json structure but since the way it is, I cannot do much... I thought instead of worrying about all these details just make the code the way json it is so that it doesnt fail and return empty list if you cannot execute url for whatever reason. And that's what I did originally
Feb 11, 2017 13:09
lol
Feb 11, 2017 13:02
ok.. in this case, this will be the only class in whole my project that will be doing this and others will call it just to get the data back
Feb 11, 2017 13:01
I see
Feb 11, 2017 13:00
otherwise keep that in json response
Feb 11, 2017 12:59
now it needs to check next field and if it is false, then remove that field
Feb 11, 2017 12:59
right now execute method just executes the url and return the response
Feb 11, 2017 12:59
what will be the benefit of doing this in execute method?
Feb 11, 2017 12:57
yeah
Feb 11, 2017 12:57
what I had in my code instead of your line?
Feb 11, 2017 12:57
          hasMore = jobject.get("next").getAsBoolean();
Feb 11, 2017 12:56
do I need to do that? or can I not use this directly
Feb 11, 2017 12:55
some other team does that
Feb 11, 2017 12:55
yup and that is not under my control
Feb 11, 2017 12:55
which I cannot control unfortunately
Feb 11, 2017 12:55
yeah earlier I assumed so but this fformat is provided by some other team in our company
Feb 11, 2017 12:54
and then it will keep running forever
Feb 11, 2017 12:54
has will check the field so it will always return true
Feb 11, 2017 12:54
yeah thats what I thought
Feb 11, 2017 12:54
hasMore = jobject.has(KEY_NEXT);
Feb 11, 2017 12:54
and in your code I see this line
Feb 11, 2017 12:54
but some times it will be true, so there is another url at the bottom which I need to use to get annother set of ids and keep repeating
Feb 11, 2017 12:53
most of the time with the first json response, it will be false and that means there is no url at the bottom of the json..
Feb 11, 2017 12:53
"next": true,
Feb 11, 2017 12:53
I am talking about this
Feb 11, 2017 12:50
yeah that I know but with the current way execute has, you mean to say I should throw at the last retry attempt then?
Feb 11, 2017 12:50
what will has do here? it will check whether field is there in the json but it wont check whether it is true or false?
Feb 11, 2017 12:49
hasMore = jobject.has(KEY_NEXT);
Feb 11, 2017 12:49
but key next will be present there but it will be false so that means there is no another set of url at the bottom
Feb 11, 2017 12:49
Also in many cases, next boolean will be false
Feb 11, 2017 12:47
hey saw the edit and I understood now.. So if I have to retry execute method say 3 times, how can I do that now since it throws RuntimeException now in the catch block so I might not be able to retry anymore? right? or I missed anything?
Feb 11, 2017 12:46
I also edited my question to add execute method which executes the URL.. Just to give you some idea how it looks like.. In my case, I am thinking to retry execute method few times if it throws exception. Because I want to get the data back at any cost by executing these url's. So for whatever reason first time, it gave IOException or Timedout for whatever reason, I can try calling execute method few times to make sure it give the response back.
Feb 11, 2017 12:46
hmmm so what I am supposed to do in PartialResultException constructor? Also I am not sure under what cases NoSuchElementException exception will be thrown. In my case, I can throw IOException since I am executing URL and that is what the exception can get thrown in that method.
Feb 11, 2017 12:46
Thanks for the great feedback. In my case, if for whatever reason, I am not able to parse response or execute URL properly, then I am returning empty List back. I guess that's ok in my use case here. Also to execute URL, I am using AsyncHttpClient which executes URL and return whole JSON response back as a String. And since executing URL can give some IOException or `TimeoutException', didn't got a response within a particular time, so that is why I return Optional<String> back as well.
 
Jun 7, 2015 21:35
bye
Jun 7, 2015 21:32
sure
Jun 7, 2015 21:24
sorry guys, didn't thought about these things. It's my mistake. I will definitely make a note of this. Thanks rolfl for letting me know this.
Jun 7, 2015 21:16
Sometimes, I do confuse Apache Commons with Guava
Jun 7, 2015 21:15
lot of cool features to use
Jun 7, 2015 21:15
yup, also I do like Apache Commons a lot as well, they also have
Jun 7, 2015 21:11
I see. Yeah I do like Guava a lot. It's more powerful, I wonder JDK should bring some of the features of Guava library :)
Jun 7, 2015 21:06
do they have any HttpClient?
Jun 7, 2015 21:06
yup
Jun 7, 2015 21:00
lol sure :)
Jun 7, 2015 20:57
part of Spring framework
 

 The 2nd Monitor

General discussion about codereview.stackexchange.com - Welcom...
Jun 7, 2015 21:20
@rolfl sure I will make a note of this next time. I was not aware of this. Sorry about that.
Jun 7, 2015 21:14
sure got it. I pasted here but I realize may be its not right to do so thought to check with you. Sorry about that