@@ -88,10 +88,15 @@ public UploadTask(TransferRecord uploadInfo,
8888 */
8989 @ Override
9090 public Boolean call () throws Exception {
91- if (!isNetworkHandlerRegisteredAndNetworkConnected ()) {
92- LOGGER .info ("Network not connected. Setting the state to WAITING_FOR_NETWORK." );
93- updater .updateState (upload .id , TransferState .WAITING_FOR_NETWORK );
94- return false ;
91+ try {
92+ if (TransferNetworkLossHandler .getInstance () != null &&
93+ !TransferNetworkLossHandler .getInstance ().isNetworkConnected ()) {
94+ LOGGER .info ("Network not connected. Setting the state to WAITING_FOR_NETWORK." );
95+ updater .updateState (upload .id , TransferState .WAITING_FOR_NETWORK );
96+ return false ;
97+ }
98+ } catch (TransferUtilityException transferUtilityException ) {
99+ LOGGER .error ("TransferUtilityException: [" + transferUtilityException + "]" );
95100 }
96101
97102 updater .updateState (upload .id , TransferState .IN_PROGRESS );
@@ -174,10 +179,15 @@ private Boolean uploadMultipartAndWaitForCompletion() throws ExecutionException
174179 isSuccess &= b ;
175180 }
176181 if (!isSuccess ) {
177- if (!isNetworkHandlerRegisteredAndNetworkConnected ()) {
178- LOGGER .info ("Network not connected. Setting the state to WAITING_FOR_NETWORK." );
179- updater .updateState (upload .id , TransferState .WAITING_FOR_NETWORK );
180- return false ;
182+ try {
183+ if (TransferNetworkLossHandler .getInstance () != null &&
184+ !TransferNetworkLossHandler .getInstance ().isNetworkConnected ()) {
185+ LOGGER .info ("Network not connected. Setting the state to WAITING_FOR_NETWORK." );
186+ updater .updateState (upload .id , TransferState .WAITING_FOR_NETWORK );
187+ return false ;
188+ }
189+ } catch (TransferUtilityException transferUtilityException ) {
190+ LOGGER .error ("TransferUtilityException: [" + transferUtilityException + "]" );
181191 }
182192 }
183193 } catch (final Exception e ) {
@@ -211,10 +221,15 @@ private Boolean uploadMultipartAndWaitForCompletion() throws ExecutionException
211221 }
212222 }
213223
214- if (!isNetworkHandlerRegisteredAndNetworkConnected ()) {
215- LOGGER .info ("Network not connected. Setting the state to WAITING_FOR_NETWORK." );
216- updater .updateState (upload .id , TransferState .WAITING_FOR_NETWORK );
217- return false ;
224+ try {
225+ if (TransferNetworkLossHandler .getInstance () != null &&
226+ !TransferNetworkLossHandler .getInstance ().isNetworkConnected ()) {
227+ LOGGER .info ("Network not connected. Setting the state to WAITING_FOR_NETWORK." );
228+ updater .updateState (upload .id , TransferState .WAITING_FOR_NETWORK );
229+ return false ;
230+ }
231+ } catch (TransferUtilityException transferUtilityException ) {
232+ LOGGER .error ("TransferUtilityException: [" + transferUtilityException + "]" );
218233 }
219234
220235 // interrupted due to reasons other than network.
@@ -467,16 +482,6 @@ private static CannedAccessControlList getCannedAclFromString(String cannedAcl)
467482 return cannedAcl == null ? null : CANNED_ACL_MAP .get (cannedAcl );
468483 }
469484
470- private boolean isNetworkHandlerRegisteredAndNetworkConnected () {
471- try {
472- return TransferNetworkLossHandler .getInstance () != null &&
473- TransferNetworkLossHandler .getInstance ().isNetworkConnected ();
474- } catch (TransferUtilityException transferUtilityException ) {
475- LOGGER .error ("TransferUtilityException: [" + transferUtilityException + "]" );
476- return false ;
477- }
478- }
479-
480485 /**
481486 * Progress Listener for the Main UploadTask.
482487 */
0 commit comments