Merge pull request #1 from bartimaeusnek/master

added Nullchecks for Erroring streams
This commit is contained in:
Martin Robertz authored and GitHub committed 2019-01-01 01:38:16 +01:00
commit cb1ce93933
3 files changed
+21 -13

No files matched your search

+2 -1
View File
@@ -47,4 +47,5 @@ hs_err_pid*
*.iml
*.ipr
*.iws
.idea/
.idea/
/out
+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "1.7.10-1.0.7.4"
version = "1.7.10-1.0.7.4QF"
group= "makeo.gadomancy"
archivesBaseName = "gadomancy"
@@ -24,6 +24,7 @@ import java.util.Map;
* for more read the LICENSE file
*
* Created by makeo @ 26.07.2015 18:15
* Modified by bartimaeusnek @ 31.12.2018, 19:00 GMT+1
*/
public class ModData {
private static final Gson GSON = new Gson();
@@ -77,7 +78,7 @@ public class ModData {
}
public boolean load() {
if(file.exists()) {
if(file != null && file.exists()) {
ObjectInputStream inOBJ = null;
FileInputStream in = null;
try {
@@ -87,18 +88,21 @@ public class ModData {
} catch (IOException | ClassCastException | JsonSyntaxException | ClassNotFoundException e) { //
e.printStackTrace();
try {
inOBJ.close();
in.close();
if (inOBJ != null)
inOBJ.close();
if (in != null)
in.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return false;
} finally {
if(in != null)
try {
inOBJ.close();
in.close();
if (inOBJ != null)
inOBJ.close();
if (in != null)
in.close();
} catch (IOException ignored) { }
}
}
@@ -123,17 +127,20 @@ public class ModData {
} catch (JsonIOException | IOException e) {
e.printStackTrace();
try {
outOBJ.close();
out.close();
if (outOBJ != null)
outOBJ.close();
if(out != null)
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return false;
} finally {
if(out != null)
try {
outOBJ.close();
out.close();
if(outOBJ != null)
outOBJ.close();
if(out != null)
out.close();
} catch (IOException ignored) { }
}
return true;