diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..0a2df9277 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://www.paypal.com/paypalme/algr453'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/README.md b/README.md index 27d3a3e32..b90ef2e5f 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Who said OAuth/OAuth2 was difficult? Configuring ScribeJava is __so easy your grandma can do it__! check it out: ```java -OAuthService service = new ServiceBuilder(YOUR_API_KEY) - .apiSecret(YOUR_API_SECRET) +OAuthService service = new ServiceBuilder(YOUR_CLIENT_ID) + .apiSecret(YOUR_CLIENT_SECRET) .build(LinkedInApi20.instance()); ``` @@ -137,7 +137,7 @@ You can pull ScribeJava from the central maven repository, just add these to you com.github.scribejava scribejava-apis - 8.3.0 + 8.3.3 ``` @@ -146,7 +146,7 @@ And in case you need just core classes (that's it, without any external API (FB, com.github.scribejava scribejava-core - 8.3.0 + 8.3.3 ``` diff --git a/changelog b/changelog index b469257b6..e962e073b 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,15 @@ +[8.3.3] + * update dependencies, including security updates in libraries + +[8.3.2] + * minor fixes and enhances + * update dependencies + * while using async HTTP client, you could miss some Throwables, now they will be thrown + +[8.3.1] + * fix java.lang.NoClassDefFoundError for non-java8 runtimes (e.g. Android 7.1.1) + (thanks to https://github.com/ChristopherGittner) + [8.3.0] * add Instagram (https://www.instagram.com/) API (thanks to https://github.com/faent) * add getErrorMessage method to FacebookAccessTokenErrorResponse. Should be used instead of general getMessage method diff --git a/checkstyle.xml b/checkstyle.xml index c9b0fac9b..f7efbad65 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -96,7 +96,9 @@ - + diff --git a/donate.md b/donate.md index ee6a1a6e7..99d3686dc 100644 --- a/donate.md +++ b/donate.md @@ -1,12 +1,10 @@ You can now help ScribeJava not only by Pull Requests. -You can use [https://paypal.me/kullfar](https://paypal.me/kullfar) directly - -or try donation button from PayPal: [![Donate with PayPal button](https://www.paypalobjects.com/en_US/RU/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=E3XAUM2ET2R3Y&source=url) +You can use [https://www.paypal.com/paypalme/algr453](https://www.paypal.com/paypalme/algr453) directly. Thanks in advance! -ps.If you can't for any reason use above methods, let me know, we will find the way out. +ps.If you can't for any reason use above method, let me know, we will find the way out. Hall of fame "Donors" (in alphabetical order, if you don't want to be here, just put a note along with the donation):
1.Douglas Ross from USA
diff --git a/pmd.xml b/pmd.xml index 7b5314710..5d93d340b 100644 --- a/pmd.xml +++ b/pmd.xml @@ -17,7 +17,6 @@ - @@ -34,8 +33,6 @@ - - @@ -48,6 +45,7 @@ + @@ -91,7 +89,6 @@ - diff --git a/pom.xml b/pom.xml index 054ef33bb..b484b6a71 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.scribejava scribejava pom - 8.3.0 + 8.3.4-SNAPSHOT ScribeJava OAuth Library The best OAuth library out there https://github.com/scribejava/scribejava @@ -33,10 +33,10 @@ - scm:git:git://github.com/scribejava/scribejava.git - scm:git:git@github.com:scribejava/scribejava.git + scm:git:https://github.com/scribejava/scribejava + scm:git:https://github.com/scribejava/scribejava https://github.com/scribejava/scribejava - scribejava-8.3.0 + HEAD @@ -55,7 +55,7 @@ com.fasterxml.jackson.core jackson-databind - 2.12.3 + 2.14.0 junit @@ -66,7 +66,7 @@ com.squareup.okhttp3 mockwebserver - 4.9.1 + 4.10.0 test @@ -76,7 +76,7 @@ org.apache.felix maven-bundle-plugin - 5.1.2 + 5.1.8 bundle-manifest @@ -90,7 +90,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.3.0 ${project.build.outputDirectory}/META-INF/MANIFEST.MF @@ -100,12 +100,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.1.2 + 3.2.0 com.puppycrawl.tools checkstyle - 8.41.1 + 10.4 @@ -125,19 +125,19 @@ org.apache.maven.plugins maven-clean-plugin - 3.1.0 + 3.2.0 org.apache.maven.plugins maven-install-plugin - 2.5.2 + 3.0.1 maven-compiler-plugin - 3.8.1 + 3.10.1 UTF-8 ${java.release} @@ -149,7 +149,7 @@ maven-deploy-plugin - 2.8.2 + 3.0.0 default-deploy @@ -163,7 +163,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.2.0 + 3.3.0 UTF-8 @@ -184,7 +184,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 + 3.4.1 ${java.home}/bin/javadoc UTF-8 @@ -208,7 +208,6 @@ validate validate - main/java/com/github/scribejava/core/java8/* ${basedir}/src @@ -225,7 +224,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.14.0 + 3.19.0 net.sourceforge.pmd @@ -271,7 +270,7 @@ 7 - 6.33.0 + 6.51.0 @@ -288,7 +287,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.0.1 sign-artifacts diff --git a/scribejava-apis/pom.xml b/scribejava-apis/pom.xml index a29509a4b..4e51bb8b5 100644 --- a/scribejava-apis/pom.xml +++ b/scribejava-apis/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml @@ -50,6 +50,12 @@ ${project.version} test + + io.netty + netty-resolver + 4.1.84.Final + test + diff --git a/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramAccessTokenErrorResponse.java b/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramAccessTokenErrorResponse.java index 90e8ef92a..bae3454a2 100644 --- a/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramAccessTokenErrorResponse.java +++ b/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramAccessTokenErrorResponse.java @@ -19,7 +19,7 @@ public class InstagramAccessTokenErrorResponse extends OAuthResponseException { private final String errorType; private final int code; private final String errorMessage; - private final Response response; + private final transient Response response; public InstagramAccessTokenErrorResponse(String errorType, int code, String errorMessage, Response response) throws IOException { diff --git a/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramService.java b/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramService.java index 03f652867..5de1f3782 100644 --- a/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramService.java +++ b/scribejava-apis/src/main/java/com/github/scribejava/apis/instagram/InstagramService.java @@ -72,6 +72,9 @@ public Future getLongLivedAccessToken(OAuth2AccessToken acces * * @param accessToken short-lived access token * @return long-lived access token with filled expireIn and refreshToken + * @throws java.lang.InterruptedException + * @throws java.util.concurrent.ExecutionException + * @throws java.io.IOException */ public OAuth2AccessToken getLongLivedAccessToken(OAuth2AccessToken accessToken) throws InterruptedException, ExecutionException, IOException { diff --git a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncApacheExample.java b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncApacheExample.java similarity index 89% rename from scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncApacheExample.java rename to scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncApacheExample.java index 29d8dba96..392348b2b 100644 --- a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncApacheExample.java +++ b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncApacheExample.java @@ -3,7 +3,7 @@ import java.util.Random; import java.util.Scanner; import java.util.concurrent.ExecutionException; -import com.github.scribejava.apis.FacebookApi; +import com.github.scribejava.apis.VkontakteApi; import com.github.scribejava.core.builder.ServiceBuilder; import com.github.scribejava.core.model.OAuth2AccessToken; import com.github.scribejava.core.model.OAuthRequest; @@ -13,12 +13,13 @@ import com.github.scribejava.httpclient.apache.ApacheHttpClientConfig; import java.io.IOException; -public class FacebookAsyncApacheExample { +public class VkontakteAsyncApacheExample { - private static final String NETWORK_NAME = "Facebook"; - private static final String PROTECTED_RESOURCE_URL = "https://graph.facebook.com/v3.2/me"; + private static final String NETWORK_NAME = "vk.com"; + private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v=" + + VkontakteApi.VERSION; - private FacebookAsyncApacheExample() { + private VkontakteAsyncApacheExample() { } @SuppressWarnings("PMD.SystemPrintln") @@ -28,11 +29,11 @@ public static void main(String... args) throws InterruptedException, ExecutionEx final String clientSecret = "your client secret"; final String secretState = "secret" + new Random().nextInt(999_999); - try (OAuth20Service service = new ServiceBuilder(clientId) + try ( OAuth20Service service = new ServiceBuilder(clientId) .apiSecret(clientSecret) .callback("http://www.example.com/oauth_callback/") .httpClientConfig(ApacheHttpClientConfig.defaultConfig()) - .build(FacebookApi.instance())) { + .build(VkontakteApi.instance())) { final Scanner in = new Scanner(System.in, "UTF-8"); System.out.println("=== " + NETWORK_NAME + "'s Async OAuth Workflow ==="); @@ -73,7 +74,7 @@ public static void main(String... args) throws InterruptedException, ExecutionEx System.out.println("Now we're going to access a protected resource..."); final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); service.signRequest(accessToken, request); - try (Response response = service.execute(request)) { + try ( Response response = service.execute(request)) { System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getCode()); diff --git a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncNingExample.java b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncNingExample.java similarity index 90% rename from scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncNingExample.java rename to scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncNingExample.java index 29c52cbad..bfb80d1a9 100644 --- a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncNingExample.java +++ b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncNingExample.java @@ -5,7 +5,7 @@ import java.util.Random; import java.util.Scanner; import java.util.concurrent.ExecutionException; -import com.github.scribejava.apis.FacebookApi; +import com.github.scribejava.apis.VkontakteApi; import com.github.scribejava.core.builder.ServiceBuilder; import com.github.scribejava.core.model.OAuth2AccessToken; import com.github.scribejava.core.model.OAuthRequest; @@ -14,12 +14,13 @@ import com.github.scribejava.core.oauth.OAuth20Service; import java.io.IOException; -public class FacebookAsyncNingExample { +public class VkontakteAsyncNingExample { - private static final String NETWORK_NAME = "Facebook"; - private static final String PROTECTED_RESOURCE_URL = "https://graph.facebook.com/v3.2/me"; + private static final String NETWORK_NAME = "vk.com"; + private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v=" + + VkontakteApi.VERSION; - private FacebookAsyncNingExample() { + private VkontakteAsyncNingExample() { } @SuppressWarnings("PMD.SystemPrintln") @@ -36,11 +37,11 @@ public static void main(String... args) throws InterruptedException, ExecutionEx .setReadTimeout(1_000) .build()); - try (OAuth20Service service = new ServiceBuilder(clientId) + try ( OAuth20Service service = new ServiceBuilder(clientId) .apiSecret(clientSecret) .callback("http://www.example.com/oauth_callback/") .httpClientConfig(clientConfig) - .build(FacebookApi.instance())) { + .build(VkontakteApi.instance())) { final Scanner in = new Scanner(System.in, "UTF-8"); System.out.println("=== " + NETWORK_NAME + "'s Async OAuth Workflow ==="); @@ -81,7 +82,7 @@ public static void main(String... args) throws InterruptedException, ExecutionEx System.out.println("Now we're going to access a protected resource..."); final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); service.signRequest(accessToken, request); - try (Response response = service.execute(request)) { + try ( Response response = service.execute(request)) { System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getCode()); diff --git a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java index 2b6e2d4f7..3e4d2d363 100644 --- a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java +++ b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java @@ -9,7 +9,7 @@ public class VkontakteClientCredentialsGrantExample { - private static final String NETWORK_NAME = "Vkontakte.ru"; + private static final String NETWORK_NAME = "vk.com>"; private VkontakteClientCredentialsGrantExample() { } diff --git a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExample.java b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExample.java index baa4dae91..ca1a698bf 100644 --- a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExample.java +++ b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExample.java @@ -15,7 +15,7 @@ public class VkontakteExample { - private static final String NETWORK_NAME = "Vkontakte.ru"; + private static final String NETWORK_NAME = "vk.com"; private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v=" + VkontakteApi.VERSION; @@ -66,7 +66,7 @@ public static void main(String... args) throws IOException, InterruptedException System.out.println("Now we're going to access a protected resource..."); final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); service.signRequest(accessToken, request); - try (Response response = service.execute(request)) { + try ( Response response = service.execute(request)) { System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getCode()); diff --git a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExternalHttpExample.java b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExternalHttpExample.java index 7f9e0c969..fe5340294 100644 --- a/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExternalHttpExample.java +++ b/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExternalHttpExample.java @@ -16,7 +16,7 @@ public class VkontakteExternalHttpExample { - private static final String NETWORK_NAME = "Vkontakte.ru"; + private static final String NETWORK_NAME = "vk.com"; private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v=" + VkontakteApi.VERSION; @@ -37,7 +37,7 @@ public static void main(String... args) throws IOException, InterruptedException .setReadTimeout(1_000) .build(); //wrap it - try (DefaultAsyncHttpClient ahcHttpClient = new DefaultAsyncHttpClient(httpClientConfig)) { + try ( DefaultAsyncHttpClient ahcHttpClient = new DefaultAsyncHttpClient(httpClientConfig)) { //wrap it final AhcHttpClient wrappedAHCHttpClient = new AhcHttpClient(ahcHttpClient); @@ -74,7 +74,7 @@ public static void main(String... args) throws IOException, InterruptedException System.out.println("Now we're going to access a protected resource..."); final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); service.signRequest(accessToken, request); - try (Response response = service.execute(request)) { + try ( Response response = service.execute(request)) { System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getCode()); diff --git a/scribejava-core/pom.xml b/scribejava-core/pom.xml index f49ec30fb..d5fbfc488 100644 --- a/scribejava-core/pom.xml +++ b/scribejava-core/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml @@ -29,7 +29,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 3.0.0 + 4.0.0 true diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/base64/CommonsCodecBase64.java b/scribejava-core/src/main/java/com/github/scribejava/core/base64/CommonsCodecBase64.java index 196a6c4f0..bb172d720 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/base64/CommonsCodecBase64.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/base64/CommonsCodecBase64.java @@ -2,10 +2,18 @@ public class CommonsCodecBase64 extends Base64 { - private static final org.apache.commons.codec.binary.Base64 BASE64_ENCODER - = new org.apache.commons.codec.binary.Base64(); - private static final org.apache.commons.codec.binary.Base64 BASE64_URL_ENCODER_WITHOUT_PADDING - = new org.apache.commons.codec.binary.Base64(0, null, true); + private static final org.apache.commons.codec.binary.Base64 BASE64_ENCODER; + private static final org.apache.commons.codec.binary.Base64 BASE64_URL_ENCODER_WITHOUT_PADDING; + + static { + if (isAvailable()) { + BASE64_ENCODER = new org.apache.commons.codec.binary.Base64(); + BASE64_URL_ENCODER_WITHOUT_PADDING = new org.apache.commons.codec.binary.Base64(0, null, true); + } else { + BASE64_ENCODER = null; + BASE64_URL_ENCODER_WITHOUT_PADDING = null; + } + } @Override protected String internalEncode(byte[] bytes) { diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/base64/Java8Base64.java b/scribejava-core/src/main/java/com/github/scribejava/core/base64/Java8Base64.java index a5cea8755..8e4c6c990 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/base64/Java8Base64.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/base64/Java8Base64.java @@ -3,7 +3,7 @@ public class Java8Base64 extends Base64 { private static final com.github.scribejava.java8.base64.Java8Base64 JAVA8_BASE64 - = new com.github.scribejava.java8.base64.Java8Base64(); + = isAvailable() ? new com.github.scribejava.java8.base64.Java8Base64() : null; @Override protected String internalEncode(byte[] bytes) { diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/AbstractAsyncOnlyHttpClient.java b/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/AbstractAsyncOnlyHttpClient.java index 48917eb60..10b3d5faa 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/AbstractAsyncOnlyHttpClient.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/AbstractAsyncOnlyHttpClient.java @@ -1,6 +1,6 @@ package com.github.scribejava.core.httpclient; -import com.github.scribejava.core.model.OAuthRequest; +import com.github.scribejava.core.model.OAuthAsyncRequestCallback; import com.github.scribejava.core.model.Response; import com.github.scribejava.core.model.Verb; import java.io.File; @@ -14,8 +14,17 @@ public abstract class AbstractAsyncOnlyHttpClient implements HttpClient { public Response execute(String userAgent, Map headers, Verb httpVerb, String completeUrl, byte[] bodyContents) throws InterruptedException, ExecutionException, IOException { - return executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, null, - (OAuthRequest.ResponseConverter) null).get(); + final OAuthAsyncRequestThrowableHolderCallback oAuthAsyncRequestThrowableHolderCallback + = new OAuthAsyncRequestThrowableHolderCallback(); + + final Response response = executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, + oAuthAsyncRequestThrowableHolderCallback, null).get(); + + final Throwable throwable = oAuthAsyncRequestThrowableHolderCallback.getThrowable(); + if (throwable != null) { + throw new ExecutionException(throwable); + } + return response; } @Override @@ -23,23 +32,71 @@ public Response execute(String userAgent, Map headers, Verb http com.github.scribejava.core.httpclient.multipart.MultipartPayload bodyContents) throws InterruptedException, ExecutionException, IOException { - return executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, null, - (OAuthRequest.ResponseConverter) null).get(); + final OAuthAsyncRequestThrowableHolderCallback oAuthAsyncRequestThrowableHolderCallback + = new OAuthAsyncRequestThrowableHolderCallback(); + + final Response response = executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, + oAuthAsyncRequestThrowableHolderCallback, null).get(); + + final Throwable throwable = oAuthAsyncRequestThrowableHolderCallback.getThrowable(); + if (throwable != null) { + throw new ExecutionException(throwable); + } + + return response; } @Override public Response execute(String userAgent, Map headers, Verb httpVerb, String completeUrl, String bodyContents) throws InterruptedException, ExecutionException, IOException { - return executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, null, - (OAuthRequest.ResponseConverter) null).get(); + final OAuthAsyncRequestThrowableHolderCallback oAuthAsyncRequestThrowableHolderCallback + = new OAuthAsyncRequestThrowableHolderCallback(); + + final Response response = executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, + oAuthAsyncRequestThrowableHolderCallback, null).get(); + + final Throwable throwable = oAuthAsyncRequestThrowableHolderCallback.getThrowable(); + if (throwable != null) { + throw new ExecutionException(throwable); + } + + return response; } @Override public Response execute(String userAgent, Map headers, Verb httpVerb, String completeUrl, File bodyContents) throws InterruptedException, ExecutionException, IOException { - return executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, null, - (OAuthRequest.ResponseConverter) null).get(); + final OAuthAsyncRequestThrowableHolderCallback oAuthAsyncRequestThrowableHolderCallback + = new OAuthAsyncRequestThrowableHolderCallback(); + + final Response response = executeAsync(userAgent, headers, httpVerb, completeUrl, bodyContents, + oAuthAsyncRequestThrowableHolderCallback, null).get(); + + final Throwable throwable = oAuthAsyncRequestThrowableHolderCallback.getThrowable(); + if (throwable != null) { + throw new ExecutionException(throwable); + } + + return response; + } + + private class OAuthAsyncRequestThrowableHolderCallback implements OAuthAsyncRequestCallback { + + private Throwable throwable; + + @Override + public void onCompleted(Response response) { + } + + @Override + public void onThrowable(Throwable t) { + throwable = t; + } + + public Throwable getThrowable() { + return throwable; + } } } diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/jdk/JDKHttpFuture.java b/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/jdk/JDKHttpFuture.java index 1922d3aef..c4443cc87 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/jdk/JDKHttpFuture.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/httpclient/jdk/JDKHttpFuture.java @@ -8,6 +8,8 @@ /** * Fake Future. Just to have Future API for the default JDK Http client. It's NOT Async in any way. Just facade.
* That's it. Sync execution with Async methods. This class does NOT provide any async executions. + * + * @param */ public class JDKHttpFuture implements Future { diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuth2AccessToken.java b/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuth2AccessToken.java index 00d5b1636..f02bc57c6 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuth2AccessToken.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuth2AccessToken.java @@ -5,11 +5,9 @@ /** * Represents an OAuth 2 Access token. - *

* http://tools.ietf.org/html/rfc6749#section-5.1 * * @see OAuth 2 Access Token Specification - *

*/ public class OAuth2AccessToken extends Token { diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthResponseException.java b/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthResponseException.java index 51b46960e..5b6da25cf 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthResponseException.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthResponseException.java @@ -8,7 +8,7 @@ public class OAuthResponseException extends OAuthException { private static final long serialVersionUID = 1309424849700276816L; - private final Response response; + private final transient Response response; public OAuthResponseException(Response rawResponse) throws IOException { super(rawResponse.getBody()); diff --git a/scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java b/scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java index 89fd279b1..f48308b2e 100644 --- a/scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java +++ b/scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java @@ -39,7 +39,7 @@ public OAuth1RequestToken getRequestToken() throws IOException, InterruptedExcep final OAuthRequest request = prepareRequestTokenRequest(); log("sending request..."); - try (Response response = execute(request)) { + try ( Response response = execute(request)) { if (isDebug()) { final String body = response.getBody(); log("response status code: %s", response.getCode()); @@ -105,7 +105,7 @@ public OAuth1AccessToken getAccessToken(OAuth1RequestToken requestToken, String log("obtaining access token from %s", api.getAccessTokenEndpoint()); } final OAuthRequest request = prepareAccessTokenRequest(requestToken, oauthVerifier); - try (Response response = execute(request)) { + try ( Response response = execute(request)) { return api.getAccessTokenExtractor().extract(response); } } diff --git a/scribejava-httpclient-ahc/pom.xml b/scribejava-httpclient-ahc/pom.xml index 706c46aed..fabd225c3 100644 --- a/scribejava-httpclient-ahc/pom.xml +++ b/scribejava-httpclient-ahc/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml @@ -20,6 +20,12 @@ scribejava-core ${project.version}
+ + org.slf4j + slf4j-simple + 2.0.3 + test + org.asynchttpclient async-http-client diff --git a/scribejava-httpclient-apache/pom.xml b/scribejava-httpclient-apache/pom.xml index 4128374c1..1dc9dd53c 100644 --- a/scribejava-httpclient-apache/pom.xml +++ b/scribejava-httpclient-apache/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml @@ -28,7 +28,7 @@ org.apache.httpcomponents httpasyncclient - 4.1.4 + 4.1.5 com.github.scribejava diff --git a/scribejava-httpclient-armeria/pom.xml b/scribejava-httpclient-armeria/pom.xml index 4872949dd..54e58c619 100644 --- a/scribejava-httpclient-armeria/pom.xml +++ b/scribejava-httpclient-armeria/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml @@ -20,10 +20,16 @@ scribejava-core ${project.version} + + org.slf4j + slf4j-simple + 2.0.3 + test + com.linecorp.armeria armeria - 1.6.0 + 1.20.2 com.github.scribejava diff --git a/scribejava-httpclient-ning/pom.xml b/scribejava-httpclient-ning/pom.xml index a80cfa93f..39696d698 100644 --- a/scribejava-httpclient-ning/pom.xml +++ b/scribejava-httpclient-ning/pom.xml @@ -5,10 +5,10 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml - + com.github.scribejava scribejava-httpclient-ning ScribeJava Ning Async Http Client support @@ -20,6 +20,12 @@ scribejava-core ${project.version} + + org.slf4j + slf4j-simple + 2.0.3 + test + com.ning async-http-client diff --git a/scribejava-httpclient-okhttp/pom.xml b/scribejava-httpclient-okhttp/pom.xml index 88a4ade95..59bc2bffc 100644 --- a/scribejava-httpclient-okhttp/pom.xml +++ b/scribejava-httpclient-okhttp/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml @@ -23,7 +23,7 @@ com.squareup.okhttp3 okhttp - 4.9.1 + 4.10.0 com.github.scribejava diff --git a/scribejava-java8/pom.xml b/scribejava-java8/pom.xml index 2df10aee0..b75f6d2de 100644 --- a/scribejava-java8/pom.xml +++ b/scribejava-java8/pom.xml @@ -5,7 +5,7 @@ com.github.scribejava scribejava - 8.3.0 + 8.3.4-SNAPSHOT ../pom.xml