Skip to content

Commit a48753c

Browse files
Pdf box memory usage (#918)
* Encode with UTF-8 if getString has funny characters * Fix streams concurrency issues Issue:202643 * Bump PDFBox to 3.0.3 and improve memory usage Issue:202734 * Fix font loading --------- Co-authored-by: iroqueta <[email protected]>
1 parent 7cabd4b commit a48753c

File tree

3 files changed

+123
-109
lines changed

3 files changed

+123
-109
lines changed

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<dependency>
121121
<groupId>org.apache.pdfbox</groupId>
122122
<artifactId>pdfbox</artifactId>
123-
<version>2.0.27</version>
123+
<version>3.0.3</version>
124124
</dependency>
125125
<dependency>
126126
<groupId>org.jsoup</groupId>

java/src/main/java/com/genexus/internet/HttpClientJavaLib.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -718,23 +718,16 @@ public String getString() {
718718
return "";
719719
try {
720720
this.setEntity();
721-
ContentType contentType = ContentType.getOrDefault(entity);
722-
Charset charset;
723-
if (contentType.equals(ContentType.DEFAULT_TEXT)) {
724-
charset = StandardCharsets.UTF_8;
725-
} else {
726-
charset = contentType.getCharset();
727-
if (charset == null) {
728-
charset = StandardCharsets.UTF_8;
729-
}
730-
}
721+
Charset charset = ContentType.getOrDefault(entity).getCharset();
731722
String res = EntityUtils.toString(entity, charset);
723+
if (res.matches(".*[Ã-ÿ].*")) {
724+
res = EntityUtils.toString(entity, StandardCharsets.UTF_8);
725+
}
732726
eof = true;
733727
return res;
734728
} catch (IOException e) {
735729
setExceptionsCatch(e);
736-
} catch (IllegalArgumentException e) {
737-
}
730+
} catch (IllegalArgumentException e) {}
738731
return "";
739732
}
740733

0 commit comments

Comments
 (0)