Skip to content

NullPointerException: ServerlessHttpServletRequest.getInputStream content is Nullable  #1192

@npeters

Description

@npeters

Describe the bug
Version 4.1.3 (main branch)

https://github.com/spring-cloud/spring-cloud-function/blob/ba2db77f8045c927ac8caa35d036afbabdeaebbc/spring-cloud-function-adapters/spring-cloud-function-serverless-web/src/main/java/org/springframework/cloud/function/serverless/web/ServerlessHttpServletRequest.java#L284C2-L314C3

@Override
	public ServletInputStream getInputStream() {
		InputStream stream = new ByteArrayInputStream(this.content);
		return new ServletInputStream() {

			boolean finished = false;

			@Override
			public int read() throws IOException {
				int readByte = stream.read();
				if (readByte == -1) {
					finished = true;
				}
				return readByte;
			}

			@Override
			public void setReadListener(ReadListener readListener) {
			}

			@Override
			public boolean isReady() {
				return !finished;
			}

			@Override
			public boolean isFinished() {
				return finished;
			}
		};
	}

and content is declared nullable

@Nullable
private byte[] content;

It can append when the body of POST request is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions