File tree Expand file tree Collapse file tree 8 files changed +19
-12
lines changed
src/main/java/org/ohnlp/backbone/api/components/xlang/python Expand file tree Collapse file tree 8 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 3131 <parent >
3232 <groupId >org.ohnlp.backbone</groupId >
3333 <artifactId >backbone-parent</artifactId >
34- <version >3.0.30 </version >
34+ <version >3.0.31 </version >
3535 </parent >
3636
3737 <artifactId >api</artifactId >
Original file line number Diff line number Diff line change @@ -129,8 +129,7 @@ private void extractPythonResourcesIfNotExists() {
129129 }
130130 if (!CLEANUP_ENVS_ON_SHUTDOWN ) {
131131 boolean reinit = false ;
132- try {
133- InputStream bundleIS = findBundle ();
132+ try (InputStream bundleIS = findBundle ()) {
134133 byte [] data = bundleIS .readAllBytes ();
135134 String currModuleChecksum = new BigInteger (1 , MessageDigest .getInstance ("MD5" ).digest (data )).toString (16 );
136135 if (currModuleChecksum .equals (cachedModuleChecksum )) {
@@ -203,9 +202,17 @@ private void extractPythonResourcesIfNotExists() {
203202 pathRelative = pathRelative .replaceAll ("^" + File .separator + "?python_resources" + File .separator , "" );
204203 File pathInTmp = new File (workDir , pathRelative );
205204 pathInTmp .getParentFile ().mkdirs ();
206- byte [] contents = jar .getInputStream (entry ).readAllBytes ();
207- try (FileOutputStream fos = new FileOutputStream (pathInTmp )) {
208- fos .write (contents );
205+ try (InputStream inputStream = jar .getInputStream (entry );
206+ FileOutputStream fos = new FileOutputStream (pathInTmp )) {
207+
208+ // Define a buffer to transfer data in chunks
209+ byte [] buffer = new byte [8192 ]; // 8KB buffer
210+ int bytesRead ;
211+
212+ // Copy data in chunks from the JAR entry input stream to the output file
213+ while ((bytesRead = inputStream .read (buffer )) != -1 ) {
214+ fos .write (buffer , 0 , bytesRead );
215+ }
209216 fos .flush ();
210217 }
211218 }
Original file line number Diff line number Diff line change 77 <parent >
88 <groupId >org.ohnlp.backbone</groupId >
99 <artifactId >backbone-parent</artifactId >
10- <version >3.0.30 </version >
10+ <version >3.0.31 </version >
1111 </parent >
1212
1313 <artifactId >core</artifactId >
Original file line number Diff line number Diff line change 77 <parent >
88 <groupId >org.ohnlp.backbone</groupId >
99 <artifactId >backbone-parent</artifactId >
10- <version >3.0.30 </version >
10+ <version >3.0.31 </version >
1111 </parent >
1212
1313 <artifactId >example-backbone-configs</artifactId >
Original file line number Diff line number Diff line change 77 <parent >
88 <groupId >org.ohnlp.backbone</groupId >
99 <artifactId >backbone-parent</artifactId >
10- <version >3.0.30 </version >
10+ <version >3.0.31 </version >
1111 </parent >
1212
1313 <groupId >org.ohnlp.backbone.io</groupId >
Original file line number Diff line number Diff line change 77 <parent >
88 <groupId >org.ohnlp.backbone</groupId >
99 <artifactId >backbone-parent</artifactId >
10- <version >3.0.30 </version >
10+ <version >3.0.31 </version >
1111 </parent >
1212
1313 <artifactId >plugin-manager</artifactId >
Original file line number Diff line number Diff line change 77 <parent >
88 <groupId >org.ohnlp.backbone</groupId >
99 <artifactId >backbone-parent</artifactId >
10- <version >3.0.30 </version >
10+ <version >3.0.31 </version >
1111 </parent >
1212
1313 <groupId >org.ohnlp.backbone.transforms</groupId >
Original file line number Diff line number Diff line change 66
77 <groupId >org.ohnlp.backbone</groupId >
88 <artifactId >backbone-parent</artifactId >
9- <version >3.0.30 </version >
9+ <version >3.0.31 </version >
1010
1111
1212 <properties >
You can’t perform that action at this time.
0 commit comments