Skip to content

Commit

Permalink
attempting to fix menory issues in java plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryGeorgist committed Jun 17, 2024
1 parent 4775eeb commit 3f78762
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/main/java/usace/cc/plugin/FileDataStoreS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,33 @@ public Boolean Copy(FileDataStore destStore, String srcPath, String destPath) {
}
@Override
public InputStream Get(String path) {
byte[] data;
//byte[] data;
try {
data = GetObject(path);
ByteArrayInputStream bias = new ByteArrayInputStream(data);
return bias;
} catch (RemoteException e) {
S3Object fullObject = null;
String key = postFix + "/" + path;
System.out.println(path);
System.out.println(bucket);
try {
fullObject = awsS3.getObject(new GetObjectRequest(bucket, key));
System.out.println("Content-Type: " + fullObject.getObjectMetadata().getContentType());
return fullObject.getObjectContent();
} catch (Exception e) {
throw e;
} finally {
// To ensure that the network connection doesn't remain open, close any open input streams.
if (fullObject != null) {
try {
fullObject.close();
} catch (Exception e) {
System.out.println("key " + key + " failed to download.\n" + e.getMessage());
throw e;

//return fullObject.getObjectContent();
}
}
}

} catch (Exception e) {
e.printStackTrace();
return null;
}
Expand Down

0 comments on commit 3f78762

Please sign in to comment.