dangtranduc / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

don't throw checked Exceptions as unchecked in ExtensibleClient.callMethod() #222

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Recommend throw IOException or wrap IOExceptions with FacebookException

using facebook-java-api 2.1.1:

java.lang.RuntimeException: java.net.SocketException: Software caused
connection abort: recv failed
    at
com.google.code.facebookapi.ExtensibleClient.runtimeException(ExtensibleClient.j
ava:1818)
    at
com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:53
8)
    at
com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:45
8)
    at
com.google.code.facebookapi.ExtensibleClient.auth_expireSession(ExtensibleClient
.java:1434)
    at
org.limewire.facebook.service.FacebookFriendConnection.expireSession(FacebookFri
endConnection.java:366)
    at
org.limewire.facebook.service.FacebookFriendConnection.endChatSession(FacebookFr
iendConnection.java:303)
    at
org.limewire.facebook.service.FacebookFriendConnection.closeConnection(FacebookF
riendConnection.java:283)
    at
org.limewire.facebook.service.FacebookFriendConnection.loginImpl(FacebookFriendC
onnection.java:408)
    at
org.limewire.facebook.service.FacebookFriendService.loginImpl(FacebookFriendServ
ice.java:157)
    at
org.limewire.facebook.service.FacebookFriendService$2.call(FacebookFriendService
.java:140)
    at
org.limewire.facebook.service.FacebookFriendService$2.call(FacebookFriendService
.java:137)
    at
org.limewire.concurrent.ErrorCatchingThreadPoolExecutor$1.call(ErrorCatchingThre
adPoolExecutor.java:42)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
   Caused by: java.net.SocketException: Software caused connection abort:
recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
    at
com.google.code.facebookapi.ExtensibleClient.postRequest(ExtensibleClient.java:5
65)
    at
com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:53
4)
    ... 15 more 

Original issue reported on code.google.com by tim.jul...@gmail.com on 6 Jul 2009 at 4:50

GoogleCodeExporter commented 9 years ago
I'm attaching two possible patches. One patch wraps the IOException in a
FacebookException which is already being thrown by callMethod().  The other 
patch
throws IOException.  That is a more invasive change b/c it forces every API 
method to
throw it, but it is probably the preferred way the API should work.

As a bit of background, without any fixes to this, we will have to wrap all
ExtensibleClient calls in try {} catch (RuntimeException re){}, which is highly
undesirable.

Original comment by tim.jul...@gmail.com on 6 Jul 2009 at 7:35

Attachments:

GoogleCodeExporter commented 9 years ago
The issue that was reported to our bug server:

https://www.limewire.org/jira/browse/LWC-3678

Original comment by tim.jul...@gmail.com on 6 Jul 2009 at 7:50

GoogleCodeExporter commented 9 years ago
sorry to have this fallen in the cracks, but I'm really torn.  I have been 
slowly
become a fan of the "fewer checked exceptions" (mostly coming from spring and 
what
not).  I believe most users will simply wrap with a try/catch and swallow 
errors, or
simply re-throw them to someone else higher above.. so as a RuntimeException it 
would
be better.. but like I said, we can discuss.

Original comment by fern...@gmail.com on 1 Nov 2009 at 1:21