|
22 | 22 | import com.github.mustachejava.DefaultMustacheFactory; |
23 | 23 | import com.github.mustachejava.Mustache; |
24 | 24 | import com.github.mustachejava.MustacheFactory; |
25 | | -import java.io.BufferedReader; |
26 | 25 | import java.io.IOException; |
27 | 26 | import java.io.InputStream; |
28 | | -import java.io.InputStreamReader; |
29 | 27 | import java.io.StringReader; |
30 | 28 | import java.io.StringWriter; |
31 | 29 | import java.net.Authenticator; |
@@ -55,21 +53,14 @@ public class TemplateMergeService { |
55 | 53 |
|
56 | 54 | private final FineractProperties fineractProperties; |
57 | 55 |
|
58 | | - // TODO Replace this with appropriate alternative available in Guava |
| 56 | + // Simplified using Java 11+ InputStream.readAllBytes() instead of manual buffering |
59 | 57 | private static String getStringFromInputStream(final InputStream is) { |
60 | | - final StringBuilder sb = new StringBuilder(); |
61 | | - |
62 | | - String line; |
63 | | - try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { |
64 | | - |
65 | | - while ((line = br.readLine()) != null) { |
66 | | - sb.append(line); |
67 | | - } |
| 58 | + try { |
| 59 | + return new String(is.readAllBytes(), StandardCharsets.UTF_8); |
68 | 60 | } catch (final IOException e) { |
69 | 61 | log.error("getStringFromInputStream() failed", e); |
| 62 | + return ""; |
70 | 63 | } |
71 | | - |
72 | | - return sb.toString(); |
73 | 64 | } |
74 | 65 |
|
75 | 66 | public String compile(final Template template, final Map<String, Object> scopes) { |
|
0 commit comments