Skip to content

Commit 3f78762

Browse files
committed
attempting to fix menory issues in java plugins.
1 parent 4775eeb commit 3f78762

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/main/java/usace/cc/plugin/FileDataStoreS3.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,33 @@ public Boolean Copy(FileDataStore destStore, String srcPath, String destPath) {
4747
}
4848
@Override
4949
public InputStream Get(String path) {
50-
byte[] data;
50+
//byte[] data;
5151
try {
52-
data = GetObject(path);
53-
ByteArrayInputStream bias = new ByteArrayInputStream(data);
54-
return bias;
55-
} catch (RemoteException e) {
52+
S3Object fullObject = null;
53+
String key = postFix + "/" + path;
54+
System.out.println(path);
55+
System.out.println(bucket);
56+
try {
57+
fullObject = awsS3.getObject(new GetObjectRequest(bucket, key));
58+
System.out.println("Content-Type: " + fullObject.getObjectMetadata().getContentType());
59+
return fullObject.getObjectContent();
60+
} catch (Exception e) {
61+
throw e;
62+
} finally {
63+
// To ensure that the network connection doesn't remain open, close any open input streams.
64+
if (fullObject != null) {
65+
try {
66+
fullObject.close();
67+
} catch (Exception e) {
68+
System.out.println("key " + key + " failed to download.\n" + e.getMessage());
69+
throw e;
70+
71+
//return fullObject.getObjectContent();
72+
}
73+
}
74+
}
75+
76+
} catch (Exception e) {
5677
e.printStackTrace();
5778
return null;
5879
}

0 commit comments

Comments
 (0)