Skip to content

Commit

Permalink
Deprecate OpenSlide.dispose()
Browse files Browse the repository at this point in the history
close() is more idiomatic because of Closeable and has existed since 2010.

Signed-off-by: Benjamin Gilbert <[email protected]>
  • Loading branch information
bgilbert committed Apr 17, 2024
1 parent a7a9689 commit ff8fe5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions org/openslide/OpenSlide.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,22 @@ public OpenSlide(File file) throws IOException {
hashCodeVal = canonicalFile.hashCode();
}
} catch (IOException e) {
// dispose, we are in the constructor
dispose();
// close, we are in the constructor
close();
throw e;
}
}

public void dispose() {
@Override
public void close() {
errorCtx.getOsr().close();
}

@Deprecated
public void dispose() {
close();
}

public int getLevelCount() {
return levelCount;
}
Expand Down Expand Up @@ -445,9 +451,4 @@ public boolean equals(Object obj) {

return false;
}

@Override
public void close() {
dispose();
}
}
4 changes: 2 additions & 2 deletions org/openslide/TestCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void main(String args[]) throws IOException {

long w, h;

osr.dispose();
osr.close();

try (OpenSlideCache cache = new OpenSlideCache(64 << 20)) {
osr = new OpenSlide(f);
Expand Down Expand Up @@ -83,6 +83,6 @@ public static void main(String args[]) throws IOException {
test_next_biggest(osr, 1000);
test_next_biggest(osr, 10000);

osr.dispose();
osr.close();
}
}

0 comments on commit ff8fe5e

Please sign in to comment.