diff --git a/TransifexNativeSDK/clitool/src/main/java/com/transifex/clitool/MainClass.java b/TransifexNativeSDK/clitool/src/main/java/com/transifex/clitool/MainClass.java index 426cadd..ec58eb8 100644 --- a/TransifexNativeSDK/clitool/src/main/java/com/transifex/clitool/MainClass.java +++ b/TransifexNativeSDK/clitool/src/main/java/com/transifex/clitool/MainClass.java @@ -18,10 +18,9 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; +import java.util.concurrent.TimeoutException; import java.util.logging.Logger; -import javax.naming.TimeLimitExceededException; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import picocli.CommandLine; @@ -216,7 +215,7 @@ public Integer call() throws Exception { LocaleData.TxJobStatus jobStatus = null; try { jobStatus = cdsHandler.pushSourceStrings(postData); - } catch (TimeLimitExceededException e) { + } catch (TimeoutException e) { System.out.println("Strings are queued for processing"); return 0; } @@ -270,7 +269,7 @@ public Integer call() throws Exception { LocaleData.TxJobStatus jobStatus = null; try { jobStatus = cdsHandler.pushSourceStrings(postData); - } catch (TimeLimitExceededException e) { + } catch (TimeoutException e) { System.out.println("Source string clearing is queued for processing"); return 0; } @@ -446,4 +445,4 @@ String getErrorString(@NonNull LocaleData.TxJobStatus jobStatus) { private static @NonNull String getNonDownloadedLocalesString(@NonNull HashSet nonDownloadedLocales) { return "The translations for the following locales were not downloaded: " + Arrays.toString(nonDownloadedLocales.toArray()); } -} +} \ No newline at end of file diff --git a/TransifexNativeSDK/common/src/main/java/com/transifex/common/CDSHandler.java b/TransifexNativeSDK/common/src/main/java/com/transifex/common/CDSHandler.java index b39f11b..4e15563 100644 --- a/TransifexNativeSDK/common/src/main/java/com/transifex/common/CDSHandler.java +++ b/TransifexNativeSDK/common/src/main/java/com/transifex/common/CDSHandler.java @@ -21,11 +21,10 @@ import java.net.URISyntaxException; import java.net.URL; import java.util.Set; +import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.naming.TimeLimitExceededException; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -345,11 +344,11 @@ public LocaleData.TranslationMap fetchTranslations(@Nullable String localeCode, * The job status can be either "completed" or "failed". * If everything fails, null is returned. * - * @throws TimeLimitExceededException When the server takes longer than 20 seconds to complete + * @throws TimeoutException When the server takes longer than 20 seconds to complete * processing the job. */ public @Nullable - LocaleData.TxJobStatus pushSourceStrings(@NonNull LocaleData.TxPostData postData) throws TimeLimitExceededException { + LocaleData.TxJobStatus pushSourceStrings(@NonNull LocaleData.TxPostData postData) throws TimeoutException { LocaleData.TxPostResponseData response = pushSourceStringsInternal(postData); if (response == null) { return null; @@ -462,13 +461,13 @@ LocaleData.TxJobStatus pushSourceStrings(@NonNull LocaleData.TxPostData postData * @return The job status object or null if everything failed. The job status can * be either "completed" or "failed". * - * @throws TimeLimitExceededException When the server takes longer than 20 seconds to complete + * @throws TimeoutException When the server takes longer than 20 seconds to complete * processing the job. * * @see * https://github.com/transifex/transifex-delivery/#job-status */ - private @Nullable LocaleData.TxJobStatus getJobStatus(@NonNull LocaleData.TxPostResponseData responseData) throws TimeLimitExceededException { + private @Nullable LocaleData.TxJobStatus getJobStatus(@NonNull LocaleData.TxPostResponseData responseData) throws TimeoutException { URL url = null; try { URI cdsContentURI = new URI(mCdsHost); @@ -531,7 +530,7 @@ LocaleData.TxJobStatus pushSourceStrings(@NonNull LocaleData.TxPostData postData } } - throw new TimeLimitExceededException("Server is still processing the pushed strings"); + throw new TimeoutException("Server is still processing the pushed strings"); } /** diff --git a/TransifexNativeSDK/common/src/test/java/com/transifex/common/CDSHandlerTest.java b/TransifexNativeSDK/common/src/test/java/com/transifex/common/CDSHandlerTest.java index 2156424..5900abf 100644 --- a/TransifexNativeSDK/common/src/test/java/com/transifex/common/CDSHandlerTest.java +++ b/TransifexNativeSDK/common/src/test/java/com/transifex/common/CDSHandlerTest.java @@ -11,8 +11,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.LinkedHashMap; - -import javax.naming.TimeLimitExceededException; +import java.util.concurrent.TimeoutException; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -354,7 +353,7 @@ public void testPushSourceStrings_badURL() { LocaleData.TxJobStatus jobStatus = null; try { jobStatus = cdsHandler.pushSourceStrings(postData); - } catch (TimeLimitExceededException ignored) {} + } catch (TimeoutException ignored) {} assertThat(jobStatus).isNull(); } @@ -369,7 +368,7 @@ public void testPushSourceStrings_normal() { LocaleData.TxJobStatus jobStatus = null; try { jobStatus = cdsHandler.pushSourceStrings(postData); - } catch (TimeLimitExceededException ignored) {} + } catch (TimeoutException ignored) {} assertThat(jobStatus).isNotNull(); @@ -405,7 +404,7 @@ public void testPushSourceStrings_CDSRespondsWith409_returnNull() { LocaleData.TxJobStatus jobStatus = null; try { jobStatus = cdsHandler.pushSourceStrings(postData); - } catch (TimeLimitExceededException ignored) {} + } catch (TimeoutException ignored) {} assertThat(jobStatus).isNull(); @@ -421,7 +420,7 @@ public void testPushSourceStrings_CDSRespondsWithFailedJob_returnErrorInResponse LocaleData.TxJobStatus jobStatus = null; try { jobStatus = cdsHandler.pushSourceStrings(postData); - } catch (TimeLimitExceededException ignored) {} + } catch (TimeoutException ignored) {} assertThat(jobStatus).isNotNull();