Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: throw N5NoSuchKeyException if no key when reading #37

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>37.0.0</version>
<version>38.0.1</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -120,7 +120,7 @@

<s3mock_2.12.version>0.2.5</s3mock_2.12.version>
<jaxb-api.version>2.2.2</jaxb-api.version>
<n5.version>3.2.0</n5.version>
<n5.version>3.3.0</n5.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
import java.util.List;
import java.util.stream.Collectors;

import com.amazonaws.services.s3.AmazonS3URI;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.s3.model.S3Object;
import org.janelia.saalfeldlab.n5.KeyValueAccess;
import org.janelia.saalfeldlab.n5.LockedChannel;
import org.janelia.saalfeldlab.n5.N5Exception;
Expand Down Expand Up @@ -603,7 +604,15 @@ private void checkWritable() {
@Override
public InputStream newInputStream() {

final S3ObjectInputStream in = s3.getObject(bucketName, path).getObjectContent();
final S3Object object;
try {
object = s3.getObject(bucketName, path);
} catch (final AmazonServiceException e) {
if (e.getStatusCode() == 404)
throw new N5Exception.N5NoSuchKeyException("No such key", e);
throw e;
}
final S3ObjectInputStream in = object.getObjectContent();
final S3ObjectInputStreamDrain s3in = new S3ObjectInputStreamDrain(in);
synchronized (resources) {
resources.add(s3in);
Expand Down
Loading