Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random nullpointer exception #29

Closed
fredwilliamson opened this issue Jun 9, 2020 · 2 comments
Closed

Random nullpointer exception #29

fredwilliamson opened this issue Jun 9, 2020 · 2 comments

Comments

@fredwilliamson
Copy link

Hi,
We used your API in version 2.1.0 to upload a document in S3 without having the size of the file. It worked on 95% of upload but for some of them we have the following error:

java.lang.NullPointerException: null
at alex.mojaki.s3upload.StreamTransferManager.complete(StreamTransferManager.java:322)
at XXXXX.S3Adapter.createDocument(S3Adapter.java:103)

We don't find any relation between cases where it failed or not. This is the implemantation we did with your API

public Document createDocument(Document document , InputStream stream) throws DocumentManagementException {
    StreamTransferManager manager = new StreamTransferManager(this.bucketname, getKey(document.getDocumentRef()), this.s3client){
        @Override
        public void customiseInitiateRequest(InitiateMultipartUploadRequest request) {
            super.customiseInitiateRequest(request);
            ObjectMetadata metadata = new ObjectMetadata();
            metadata.addUserMetadata("d_doc_extension" , "." + FilenameUtils.getExtension(document.getDocumentName()));
            metadata.addUserMetadata("d_doc_name" , document.getDocumentRef());
            request.setObjectMetadata(metadata);
        }
    }.partSize(30);



    try (MultiPartOutputStream os = manager.getMultiPartOutputStreams().get(0)) {
        IOUtils.copy(stream, os);
        stream.close();
    } catch (IOException e) {
        e.printStackTrace();
        throw new DocumentManagementException(e.getMessage());
    } finally {
        manager.complete();
    }



    ObjectMetadata meta =  this.getDocumentMetadata(document.getDocumentRef());
    document.setFileSize(meta.getContentLength());
    return document;
}

Can you help us to find the issue ?

Regards

@alexmojaki
Copy link
Owner

Hi, sorry this slipped my mind, but have you tried upgrading to the latest version 2.2.1?

@alexmojaki
Copy link
Owner

Closing until this gets confirmed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants