Skip to content
Snippets Groups Projects
Commit 55a2ba5b authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files
parent 6178422c
Branches
Tags
No related merge requests found
...@@ -87,7 +87,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -87,7 +87,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
boolean result = true; boolean result = true;
if (fixities != null) if (fixities != null)
{ {
InputStream is; InputStream is = null;
  • IMHO sind deklarierte Variablen immer "null" bzw. 0, siehe https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.5

  • Author Owner

    Sonst Compiler Error (JDK17) bei Prüfung auf null

    java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java:137: error: variable is might not have been initialized
                    if (is != null) {
                        ^
    1 error
  • Please register or sign in to reply
try { try {
is = retrieveEntity(storedEntityIdentifier, isRelativePath); is = retrieveEntity(storedEntityIdentifier, isRelativePath);
Checksummer checksummer = new Checksummer(is, true, true, true,true); Checksummer checksummer = new Checksummer(is, true, true, true,true);
...@@ -132,6 +132,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -132,6 +132,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
finally finally
{ {
// log.info("SLUBStoragePlugin.checkFixity() finally called"); // log.info("SLUBStoragePlugin.checkFixity() finally called");
if (is != null) {
try {
is.close();
} catch (Exception e) {
log.warn("SLUBStoragePlugin.checkFixity(), failed closing file, " + e.getMessage());
}
}
} }
} }
return result; return result;
...@@ -242,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -242,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
{ {
log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + " end=" + end); log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + " end=" + end);
byte[] bytes = new byte[(int)(end - start + 1L)]; byte[] bytes = new byte[(int)(end - start + 1L)];
RandomAccessFile file; RandomAccessFile file = null;
try try
{ {
file = new RandomAccessFile(this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r"); file = new RandomAccessFile(this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r");
...@@ -264,6 +271,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -264,6 +271,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
finally finally
{ {
// log.info("SLUBStoragePlugin.retrieveEntityByRange() finally called"); // log.info("SLUBStoragePlugin.retrieveEntityByRange() finally called");
if (file != null) {
try {
file.close();
} catch (Exception e) {
log.warn("SLUBStoragePlugin.retrieveEntitybyRange(), failed closing file, " + e.getMessage());
}
}
} }
return bytes; return bytes;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment