public R finish() throws X, DbxException {
        assertOpenAndUnfinished();

        HttpRequestor.Response response = null;
        try {
            response = httpUploader.finish();

            try {
                if (response.getStatusCode() == 200) {
                    return responseSerializer.deserialize(response.getBody());
                }
                else if (response.getStatusCode() == 409) {
                    DbxWrappedException wrapped =  DbxWrappedException.fromResponse(errorSerializer, response, this.userId);
                    throw newException(wrapped);
                }
                else {
                    throw DbxRequestUtil.unexpectedStatus(response);
                }
            } catch (JsonProcessingException ex) {
                String requestId = DbxRequestUtil.getRequestId(response);
                throw new BadResponseException(requestId, "Bad JSON in response: " + ex, ex);
            }
        } catch (IOException ex) {
            throw new NetworkIOException(ex);
        } finally {
            // Make sure input stream is closed
            if (response != null) {
                IOUtil.closeQuietly(response.getBody());
            }
            finished = true;
        }
    }
public R finish ( ) throws X , DbxException { assertOpenAndUnfinished ( ) ; HttpRequestor . Response response = null ; try { response = httpUploader . finish ( ) ; try { if ( response . getStatusCode ( ) == 200 ) { return responseSerializer . deserialize ( response . getBody ( ) ) ; } else if ( response . getStatusCode ( ) == 409 ) { DbxWrappedException wrapped = DbxWrappedException . fromResponse ( errorSerializer , response , this . userId ) ; throw newException ( wrapped ) ; } else { throw DbxRequestUtil . unexpectedStatus ( response ) ; } } catch ( JsonProcessingException ex ) { String requestId = DbxRequestUtil . getRequestId ( response ) ; throw new BadResponseException ( requestId , "Bad JSON in response: " + ex , ex ) ; } } catch ( IOException ex ) { throw new NetworkIOException ( ex ) ; } finally { if ( response != null ) { IOUtil . closeQuietly ( response . getBody ( ) ) ; } finished = true ; } }
Completes the request and returns response from the server.

This method should be called after writing data to the upload {@link OutputStream} (see
{@link #getOutputStream}).

@return Response from server

@throws X if the server sent an error response for the request
@throws DbxException if an error occurs sending the upload or reading the response
@throws IllegalStateException if this uploader has already been closed (see {@link #close}) or finished (see {@link #finish})