Skip to content

Commit

Permalink
Pdf box memory usage (#918)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
tomas-sexenian and iroqueta authored Dec 17, 2024
1 parent 7cabd4b commit a48753c
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 109 deletions.
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.27</version>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
Expand Down
17 changes: 5 additions & 12 deletions java/src/main/java/com/genexus/internet/HttpClientJavaLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,23 +718,16 @@ public String getString() {
return "";
try {
this.setEntity();
ContentType contentType = ContentType.getOrDefault(entity);
Charset charset;
if (contentType.equals(ContentType.DEFAULT_TEXT)) {
charset = StandardCharsets.UTF_8;
} else {
charset = contentType.getCharset();
if (charset == null) {
charset = StandardCharsets.UTF_8;
}
}
Charset charset = ContentType.getOrDefault(entity).getCharset();
String res = EntityUtils.toString(entity, charset);
if (res.matches(".*[Ã-ÿ].*")) {
res = EntityUtils.toString(entity, StandardCharsets.UTF_8);
}
eof = true;
return res;
} catch (IOException e) {
setExceptionsCatch(e);
} catch (IllegalArgumentException e) {
}
} catch (IllegalArgumentException e) {}
return "";
}

Expand Down
Loading

0 comments on commit a48753c

Please sign in to comment.