Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12c6b05

Browse files
committed
throw Throwable from callback (it got lost before)
1 parentd30eb24 commit12c6b05

File tree

1 file changed

+66
-9
lines changed

1 file changed

+66
-9
lines changed
Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packagecom.github.scribejava.core.httpclient;
22

3-
importcom.github.scribejava.core.model.OAuthRequest;
3+
importcom.github.scribejava.core.model.OAuthAsyncRequestCallback;
44
importcom.github.scribejava.core.model.Response;
55
importcom.github.scribejava.core.model.Verb;
66
importjava.io.File;
@@ -14,32 +14,89 @@ public abstract class AbstractAsyncOnlyHttpClient implements HttpClient {
1414
publicResponseexecute(StringuserAgent,Map<String,String>headers,VerbhttpVerb,StringcompleteUrl,
1515
byte[]bodyContents)throwsInterruptedException,ExecutionException,IOException {
1616

17-
returnexecuteAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,null,
18-
(OAuthRequest.ResponseConverter<Response>)null).get();
17+
finalOAuthAsyncRequestThrowableHolderCallbackoAuthAsyncRequestThrowableHolderCallback
18+
=newOAuthAsyncRequestThrowableHolderCallback();
19+
20+
finalResponseresponse =executeAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,
21+
oAuthAsyncRequestThrowableHolderCallback,null).get();
22+
23+
finalThrowablethrowable =oAuthAsyncRequestThrowableHolderCallback.getThrowable();
24+
if (throwable !=null) {
25+
thrownewExecutionException(throwable);
26+
}
27+
returnresponse;
1928
}
2029

2130
@Override
2231
publicResponseexecute(StringuserAgent,Map<String,String>headers,VerbhttpVerb,StringcompleteUrl,
2332
com.github.scribejava.core.httpclient.multipart.MultipartPayloadbodyContents)
2433
throwsInterruptedException,ExecutionException,IOException {
2534

26-
returnexecuteAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,null,
27-
(OAuthRequest.ResponseConverter<Response>)null).get();
35+
finalOAuthAsyncRequestThrowableHolderCallbackoAuthAsyncRequestThrowableHolderCallback
36+
=newOAuthAsyncRequestThrowableHolderCallback();
37+
38+
finalResponseresponse =executeAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,
39+
oAuthAsyncRequestThrowableHolderCallback,null).get();
40+
41+
finalThrowablethrowable =oAuthAsyncRequestThrowableHolderCallback.getThrowable();
42+
if (throwable !=null) {
43+
thrownewExecutionException(throwable);
44+
}
45+
46+
returnresponse;
2847
}
2948

3049
@Override
3150
publicResponseexecute(StringuserAgent,Map<String,String>headers,VerbhttpVerb,StringcompleteUrl,
3251
StringbodyContents)throwsInterruptedException,ExecutionException,IOException {
3352

34-
returnexecuteAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,null,
35-
(OAuthRequest.ResponseConverter<Response>)null).get();
53+
finalOAuthAsyncRequestThrowableHolderCallbackoAuthAsyncRequestThrowableHolderCallback
54+
=newOAuthAsyncRequestThrowableHolderCallback();
55+
56+
finalResponseresponse =executeAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,
57+
oAuthAsyncRequestThrowableHolderCallback,null).get();
58+
59+
finalThrowablethrowable =oAuthAsyncRequestThrowableHolderCallback.getThrowable();
60+
if (throwable !=null) {
61+
thrownewExecutionException(throwable);
62+
}
63+
64+
returnresponse;
3665
}
3766

3867
@Override
3968
publicResponseexecute(StringuserAgent,Map<String,String>headers,VerbhttpVerb,StringcompleteUrl,
4069
FilebodyContents)throwsInterruptedException,ExecutionException,IOException {
4170

42-
returnexecuteAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,null,
43-
(OAuthRequest.ResponseConverter<Response>)null).get();
71+
finalOAuthAsyncRequestThrowableHolderCallbackoAuthAsyncRequestThrowableHolderCallback
72+
=newOAuthAsyncRequestThrowableHolderCallback();
73+
74+
finalResponseresponse =executeAsync(userAgent,headers,httpVerb,completeUrl,bodyContents,
75+
oAuthAsyncRequestThrowableHolderCallback,null).get();
76+
77+
finalThrowablethrowable =oAuthAsyncRequestThrowableHolderCallback.getThrowable();
78+
if (throwable !=null) {
79+
thrownewExecutionException(throwable);
80+
}
81+
82+
returnresponse;
83+
}
84+
85+
privateclassOAuthAsyncRequestThrowableHolderCallbackimplementsOAuthAsyncRequestCallback<Response> {
86+
87+
privateThrowablethrowable;
88+
89+
@Override
90+
publicvoidonCompleted(Responseresponse) {
91+
}
92+
93+
@Override
94+
publicvoidonThrowable(Throwablet) {
95+
throwable =t;
96+
}
97+
98+
publicThrowablegetThrowable() {
99+
returnthrowable;
100+
}
44101
}
45102
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp