Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.springframework.util.StreamUtils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.time.Instant;
import java.util.HashSet;
Expand Down Expand Up @@ -349,9 +350,11 @@ public void createThemesIndices(MongoTemplate mongoTemplate) {
@ChangeSet(order = "031-a", id = "create-system-themes-v3", author = "", runAlways = true)
public void createSystemThemes3(MongoTemplate mongoTemplate) throws IOException {

final String themesJson = StreamUtils.copyToString(
new DefaultResourceLoader().getResource("system-themes.json").getInputStream(),
Charset.defaultCharset());
final String themesJson;
try (InputStream inputStream =
new DefaultResourceLoader().getResource("system-themes.json").getInputStream()) {
themesJson = StreamUtils.copyToString(inputStream, Charset.defaultCharset());
}

Theme[] themes = new GsonBuilder()
.registerTypeAdapter(Instant.class, new ISOStringToInstantConverter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ private Map<String, String> loadTemplatesFromPlugin(Plugin plugin) {
? filename.replaceFirst("\\.\\w+$", "")
: template.getTitle();

try {
templates.put(title, StreamUtils.copyToString(resource.getInputStream(), Charset.defaultCharset()));
try (InputStream inputStream = resource.getInputStream()) {
templates.put(title, StreamUtils.copyToString(inputStream, Charset.defaultCharset()));

} catch (IOException e) {
log.error("Error loading template {} for plugin {}", filename, plugin.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import reactor.core.scheduler.Schedulers;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.time.Instant;
import java.util.ArrayList;
Expand Down Expand Up @@ -590,8 +591,11 @@ private ApplicationJson fetchTemplateApplication(String filePath) throws IOExcep
3. Store the data in the application resource format
*/
log.debug("Going to fetch template application");
final String jsonContent = StreamUtils.copyToString(
new DefaultResourceLoader().getResource(filePath).getInputStream(), Charset.defaultCharset());
final String jsonContent;
try (InputStream inputStream =
new DefaultResourceLoader().getResource(filePath).getInputStream()) {
jsonContent = StreamUtils.copyToString(inputStream, Charset.defaultCharset());
}

return gson.fromJson(jsonContent, ApplicationJson.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import reactor.test.StepVerifier;

import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
Expand Down Expand Up @@ -283,8 +284,10 @@ public void importApplication_ThenExportApplication_MatchJson_equals_Success() t

@SneakyThrows
private String readResource(String filePath) {
return StreamUtils.copyToString(
new DefaultResourceLoader().getResource(filePath).getInputStream(), StandardCharsets.UTF_8);
try (InputStream inputStream =
new DefaultResourceLoader().getResource(filePath).getInputStream()) {
return StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
}
}

private void removeCustomJsLibsEntries(JsonObject applicationObjectNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import reactor.util.function.Tuple3;
import reactor.util.function.Tuple4;

import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -4965,8 +4966,10 @@ public void mergeApplicationJsonWithApplication_WhenNoPermissionToCreatePage_Fai

@SneakyThrows
private String readResource(String filePath) {
return StreamUtils.copyToString(
new DefaultResourceLoader().getResource(filePath).getInputStream(), StandardCharsets.UTF_8);
try (InputStream inputStream =
new DefaultResourceLoader().getResource(filePath).getInputStream()) {
return StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import reactor.test.StepVerifier;
import reactor.util.function.Tuple3;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.HashMap;
Expand Down Expand Up @@ -250,8 +251,10 @@ private Application createGitConnectedApp(String applicationName) {

@SneakyThrows
private String readResource(String filePath) {
return StreamUtils.copyToString(
new DefaultResourceLoader().getResource(filePath).getInputStream(), StandardCharsets.UTF_8);
try (InputStream inputStream =
new DefaultResourceLoader().getResource(filePath).getInputStream()) {
return StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
}
}

@Test
Expand Down