• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yahoo / elide / #7468

26 Apr 2026 12:33AM UTC coverage: 84.332% (-0.09%) from 84.417%
#7468

push

web-flow
Update to Spring Boot 3.5.14 and align dependencies (#3398)

* Update to Spring Boot 3.5.14 and align dependencies

* Add logs for export

2 of 55 new or added lines in 5 files covered. (3.64%)

4 existing lines in 3 files now uncovered.

19753 of 23423 relevant lines covered (84.33%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.11
/elide-async/src/main/java/com/yahoo/elide/async/service/storageengine/FileResultStorageEngine.java
1
/*
2
 * Copyright 2020, Yahoo Inc.
3
 * Licensed under the Apache License, Version 2.0
4
 * See LICENSE file in project root for terms.
5
 */
6

7
package com.yahoo.elide.async.service.storageengine;
8

9
import com.yahoo.elide.async.models.TableExportResult;
10

11
import jakarta.inject.Singleton;
12
import lombok.Getter;
13
import lombok.Setter;
14
import lombok.extern.slf4j.Slf4j;
15

16
import java.io.FileNotFoundException;
17
import java.io.IOException;
18
import java.io.InputStream;
19
import java.io.OutputStream;
20
import java.io.UncheckedIOException;
21
import java.nio.file.Files;
22
import java.nio.file.Path;
23
import java.nio.file.Paths;
24
import java.util.function.Consumer;
25

26
/**
27
 * Default implementation of ResultStorageEngine that stores results on local filesystem.
28
 * It supports Async Module to store results with Table Export query.
29
 */
30
@Singleton
31
@Slf4j
1✔
32
@Getter
33
public class FileResultStorageEngine implements ResultStorageEngine {
34
    @Setter private String basePath;
35

36
    /**
37
     * Constructor.
38
     * @param basePath basePath for storing the files. Can be absolute or relative.
39
     */
40
    public FileResultStorageEngine(String basePath) {
1✔
41
        this.basePath = basePath;
1✔
42
    }
1✔
43

44
    @Override
45
    public TableExportResult storeResults(String tableExportID, Consumer<OutputStream> result) {
46
        log.debug("store TableExportResults for Download");
1✔
47
       TableExportResult exportResult = new TableExportResult();
1✔
48
       try (OutputStream writer = newOutputStream(tableExportID)) {
1✔
49
           result.accept(writer);
1✔
50
       } catch (IOException e) {
×
51
           throw new UncheckedIOException(STORE_ERROR, e);
×
52
       }
1✔
53
       return exportResult;
1✔
54
    }
55

56
    @Override
57
    public Consumer<OutputStream> getResultsByID(String tableExportID) {
58
        log.debug("getTableExportResultsByID");
1✔
59
        return outputStream -> {
1✔
60
            try {
61
                newInputStream(tableExportID).transferTo(outputStream);
1✔
62
            } catch (IOException e) {
×
NEW
63
                log.error("Error transferring " + tableExportID + " to output stream.", e);
×
UNCOV
64
                throw new UncheckedIOException(e);
×
65
            }
1✔
66
        };
1✔
67
    }
68

69
    /**
70
     * Validates that the path to read/write is as expected to prevent path
71
     * traversal.
72
     *
73
     * @param path the path to read/write
74
     * @throws IOException if the path is not expected
75
     */
76
    protected void validatePath(Path path) throws IOException {
77
        Path parent = Paths.get(basePath);
1✔
78
        if (!path.getParent().equals(parent)) {
1✔
79
            throw new FileNotFoundException();
1✔
80
        }
81
    }
1✔
82

83
    private InputStream newInputStream(String tableExportID) {
84
        try {
85
            Path path = Paths.get(basePath, tableExportID);
1✔
86
            validatePath(path);
1✔
87
            return Files.newInputStream(path);
1✔
88
        } catch (IOException e) {
1✔
89
            log.error(RETRIEVE_ERROR, e);
1✔
90
            throw new UncheckedIOException(RETRIEVE_ERROR, e);
1✔
91
        }
92
    }
93

94
    private OutputStream newOutputStream(String tableExportID) {
95
        try {
96
            Path path = Paths.get(basePath, tableExportID);
1✔
97
            validatePath(path);
1✔
98
            return Files.newOutputStream(path);
1✔
99
        } catch (IOException e) {
1✔
100
            log.error(STORE_ERROR, e);
1✔
101
            throw new UncheckedIOException(STORE_ERROR, e);
1✔
102
        }
103
    }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc