Source:
private static FormUploadResult submitEntity(List<MultipartBody.Part> parts, String url, CommcareRequestGenerator generator) { Response<ResponseBody> response; try { response = generator.postMultipart(url, parts, new HashMap<>()); } catch (InputIOException ioe) { Logger.log(LogTypes.TYPE_ERROR_STORAGE, "Internal error reading form record during submission: " + ioe.getWrapped().getMessage()); return FormUploadResult.RECORD_FAILURE; } catch (UnknownHostException e) { e.printStackTrace(); Logger.log(LogTypes.TYPE_WARNING_NETWORK, "Client network issues during submission: " + e.getMessage()); return FormUploadResult.TRANSPORT_FAILURE; } catch (AuthenticationInterceptor.PlainTextPasswordException e) { e.printStackTrace(); Logger.log(LogTypes.TYPE_ERROR_CONFIG_STRUCTURE, "Encountered PlainTextPasswordException while submission: Sending password over HTTP"); return FormUploadResult.AUTH_OVER_HTTP; } catch (CaptivePortalRedirectException e) { e.printStackTrace(); return FormUploadResult.CAPTIVE_PORTAL; } catch (IOException | IllegalStateException e) { Logger.exception("Error reading form during submission: " + e.getMessage(), e); return FormUploadResult.TRANSPORT_FAILURE; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { if (response.body() != null) { InputStream responseStream = response.body().byteStream(); StreamsUtil.writeFromInputToOutputNew(responseStream, bos); } } catch (IllegalStateException | IOException e) { e.printStackTrace(); } String responseString = new String(bos.toByteArray()); int responseCode = response.code(); logResponse(responseCode, responseString); if (responseCode >= 200 && responseCode < 300) { return FormUploadResult.FULL_SUCCESS; } else if (responseCode == 401) { return FormUploadResult.AUTH_FAILURE; } else if (responseCode == 406) { return processActionableFaiure(response); } else if (responseCode == 422) { return handleProcessingFailure(response.errorBody().byteStream()); } else if (responseCode == 503) { return FormUploadResult.RATE_LIMITED; } else { return FormUploadResult.FAILURE; } }

Target:
private static FormUploadResult submitEntity(List<MultipartBody.Part> parts, String url, CommcareRequestGenerator generator) { Response<ResponseBody> response; try { response = generator.postMultipart(url, parts, new HashMap<>()); } catch (InputIOException ioe) { Logger.log(LogTypes.TYPE_ERROR_STORAGE, "Internal error reading form record during submission: " + ioe.getWrapped().getMessage()); return FormUploadResult.RECORD_FAILURE; } catch (UnknownHostException e) { e.printStackTrace(); Logger.log(LogTypes.TYPE_WARNING_NETWORK, "Client network issues during submission: " + e.getMessage()); return FormUploadResult.TRANSPORT_FAILURE; } catch (AuthenticationInterceptor.PlainTextPasswordException e) { e.printStackTrace(); Logger.log(LogTypes.TYPE_ERROR_CONFIG_STRUCTURE, "Encountered PlainTextPasswordException while submission: Sending password over HTTP"); return FormUploadResult.AUTH_OVER_HTTP; } catch (CaptivePortalRedirectException e) { e.printStackTrace(); Logger.log(LogTypes.TYPE_WARNING_NETWORK, "Captive portal detected while form submission"); return FormUploadResult.CAPTIVE_PORTAL; } catch (IOException | IllegalStateException e) { Logger.exception("Error reading form during submission: " + e.getMessage(), e); return FormUploadResult.TRANSPORT_FAILURE; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { if (response.body() != null) { InputStream responseStream = response.body().byteStream(); StreamsUtil.writeFromInputToOutputNew(responseStream, bos); } } catch (IllegalStateException | IOException e) { e.printStackTrace(); } String responseString = new String(bos.toByteArray()); int responseCode = response.code(); logResponse(responseCode, responseString); if (responseCode >= 200 && responseCode < 300) { return FormUploadResult.FULL_SUCCESS; } else if (responseCode == 401) { return FormUploadResult.AUTH_FAILURE; } else if (responseCode == 406) { return processActionableFaiure(response); } else if (responseCode == 422) { return handleProcessingFailure(response.errorBody().byteStream()); } else if (responseCode == 503) { return FormUploadResult.RATE_LIMITED; } else { return FormUploadResult.FAILURE; } }