I am trying to read a csv text file from S3 and then send each of its lines to a distributed queue to process them.
When I try to read this, I get a "java.net.SocketException: Socket is closed" exception at different points in the file being read (in different versions). This is the code:
AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(MyClass.class.getResourceAsStream("myCredentials.properties"))); String bucketName = "myBucket"; String key = "myFile"; S3Object object = s3.getObject(new GetObjectRequest(bucketName, key)); InputStream in = object.getObjectContent(); BufferedReader readerS3 = new BufferedReader(new InputStreamReader(in, Charset.forName(fileInfo.getEncoding()))); try { String line = null; while ((line = readerS3.readLine()) != null) {
Any idea on how to solve this problem?
UPDATE:
This exception occurs the second time I run the method, if I stop the entire program and run it again, then the first time the method is run, it works fine.
source share