Merge pull request #255 from DevFactory/release/exception-handlers-fix-1
Code Quality Improvement - Exception handlers should preserve the original exception
This commit is contained in:
@@ -10,6 +10,7 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -464,6 +465,7 @@ public class Socket extends Emitter {
|
||||
try {
|
||||
v = array.get(i);
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while retrieving data from JSONArray", e);
|
||||
v = null;
|
||||
}
|
||||
data[i] = v == JSONObject.NULL ? null : v;
|
||||
|
||||
@@ -3,11 +3,15 @@ package io.socket.hasbinary;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class HasBinary {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(HasBinary.class.getName());
|
||||
|
||||
private HasBinary() {}
|
||||
|
||||
public static boolean hasBinary(Object data) {
|
||||
@@ -29,6 +33,7 @@ public class HasBinary {
|
||||
try {
|
||||
v = _obj.isNull(i) ? null : _obj.get(i);
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while retrieving data from JSONArray", e);
|
||||
return false;
|
||||
}
|
||||
if (_hasBinary(v)) {
|
||||
@@ -44,6 +49,7 @@ public class HasBinary {
|
||||
try {
|
||||
v = _obj.get(key);
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while retrieving data from JSONObject", e);
|
||||
return false;
|
||||
}
|
||||
if (_hasBinary(v)) {
|
||||
|
||||
@@ -7,6 +7,8 @@ import org.json.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Binary {
|
||||
|
||||
@@ -14,6 +16,7 @@ public class Binary {
|
||||
|
||||
private static final String KEY_NUM = "num";
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Binary.class.getName());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static DeconstructedPacket deconstructPacket(Packet packet) {
|
||||
@@ -37,6 +40,7 @@ public class Binary {
|
||||
placeholder.put(KEY_PLACEHOLDER, true);
|
||||
placeholder.put(KEY_NUM, buffers.size());
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while putting data to JSONObject", e);
|
||||
return null;
|
||||
}
|
||||
buffers.add((byte[])data);
|
||||
@@ -49,6 +53,7 @@ public class Binary {
|
||||
try {
|
||||
newData.put(i, _deconstructPacket(_data.get(i), buffers));
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while putting packet data to JSONObject", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -62,6 +67,7 @@ public class Binary {
|
||||
try {
|
||||
newData.put(key, _deconstructPacket(_data.get(key), buffers));
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while putting data to JSONObject", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -85,6 +91,7 @@ public class Binary {
|
||||
try {
|
||||
_data.put(i, _reconstructPacket(_data.get(i), buffers));
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while putting packet data to JSONObject", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -101,6 +108,7 @@ public class Binary {
|
||||
try {
|
||||
_data.put(key, _reconstructPacket(_data.get(key), buffers));
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while putting data to JSONObject", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.json.JSONTokener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Parser {
|
||||
@@ -227,6 +228,7 @@ public class Parser {
|
||||
str.charAt(++i);
|
||||
p.data = new JSONTokener(str.substring(i)).nextValue();
|
||||
} catch (JSONException e) {
|
||||
logger.log(Level.WARNING, "An error occured while retrieving data from JSONTokener", e);
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user