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

SynchronossPartHttpMessageReader created millions of temporary directories #2277

Closed
RekaDowney opened this issue Jun 23, 2021 · 2 comments
Closed
Labels

Comments

@RekaDowney
Copy link

RekaDowney commented Jun 23, 2021

Describe the bug
I found that wheather Content-Type is multipart/form-data or application/json, SynchronossPartHttpMessageReader will create a temporal directory with prefix "synchronoss-file-upload-" every request come, and these temporal directoriese will not be cleared by docker, so now I can't execute commands such as ls in the /tmp directory.

Is it possible to postpone the execution of createTempDirectory()?

    public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implements HttpMessageReader<Part> {

	private static final String FILE_STORAGE_DIRECTORY_PREFIX = "synchronoss-file-upload-";
        private Path fileStorageDirectory = createTempDirectory();

        @Override
        public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
            return Flux.create(new SynchronossPartGenerator(message, this.fileStorageDirectory))
                    .doOnNext(part -> {
                        if (!Hints.isLoggingSuppressed(hints)) {
                            LogFormatUtils.traceDebug(logger, traceOn -> Hints.getLogPrefix(hints) + "Parsed " +
                                    (isEnableLoggingRequestDetails() ?
                                            LogFormatUtils.formatValue(part, !traceOn) :
                                            "parts '" + part.name() + "' (content masked)"));
                        }
                    });
        }

        private static Path createTempDirectory() {
            try {
                return Files.createTempDirectory(FILE_STORAGE_DIRECTORY_PREFIX);
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }

Spring Version:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
            <version>2.2.8.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.2.15.RELEASE</version>
        </dependency>

Sample
curl -XPOST -H 'Content-Type: application/json' "https://spring-cloud-gateway/path"

@RekaDowney
Copy link
Author

Whether frequent directory creation will cause the pod (in docker) memory increasing continuously, thereby affecting the stability of the application.
At present, I found that pod memory usage as high as 90% or more.

@spencergibb
Copy link
Member

Closing in favor of spring-projects/spring-framework#27092

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

No branches or pull requests

2 participants