-
Notifications
You must be signed in to change notification settings - Fork 34
Using AutoCloseable doesn't compile and I am stuck: #672
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let maps implement Closeable.
Compiles with an error: AbstractReadOnlyMap.java:32: warning: [try] auto-closeable resource AbstractReadOnlyMap<K,V> has a member method close() that could throw InterruptedException public abstract class AbstractReadOnlyMap<K, V> implements Map<K, V>, AutoCloseable { ^ where K,V are type-variables: K extends Object declared in class AbstractReadOnlyMap V extends Object declared in class AbstractReadOnlyMap "
blackwinter
reviewed
Feb 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java
index e3b1ff5d..83e68d33 100644
--- metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java
+++ metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java
@@ -16,6 +16,7 @@
package org.metafacture.metamorph.api.helpers;
+import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -31,6 +32,11 @@
*/
public abstract class AbstractReadOnlyMap<K, V> implements Map<K, V>, AutoCloseable {
+ @Override
+ public void close() throws IOException {
+ // Nothing to do
+ }
+
@Override
public final int size() {
throw new UnsupportedOperationException();
But this also appears to support my second point:
diff --git metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java
index e3b1ff5d..a43ce505 100644
--- metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java
+++ metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractReadOnlyMap.java
@@ -29,7 +29,7 @@
* @param <V> type of values
* @author Markus Michael Geipel
*/
-public abstract class AbstractReadOnlyMap<K, V> implements Map<K, V>, AutoCloseable {
+public abstract class AbstractReadOnlyMap<K, V> implements Map<K, V> {
@Override
public final int size() {
diff --git metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java
index 26d6c716..679e2b33 100644
--- metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java
+++ metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java
@@ -60,7 +60,7 @@
*
* @author Markus Michael Geipel
*/
-public final class FileMap extends AbstractReadOnlyMap<String, String> {
+public final class FileMap extends AbstractReadOnlyMap<String, String> implements AutoCloseable {
private final FileOpener fileOpener = new FileOpener();
private final Map<String, String> map = new HashMap<>();
diff --git metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java
index 64692ab1..1a192194 100644
--- metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java
+++ metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java
@@ -107,8 +107,4 @@ public void setCharsetName(final String name) {
charsetName = name;
}
- @Override
- public void close() throws IOException {
-
- }
}
I don't understand what you are pasting. |
I don't understand your confusion... The paths are right there. It's just the output of |
This PR is substituted by #667. Closing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following #667 (review):
Using AutoCloseable doesn't compile and I am stuck:
Compiles with an error:
See #666.