}
if (path.equals("/prov")) {
if (isProxyOK(req) && isProxyServer()) {
- if (super.doGetWithFallback(req, resp)) {
- return;
+ try {
+ if (super.doGetWithFallback(req, resp)) {
+ return;
+ }
+ } catch (IOException ioe) {
+ intlogger.error("Error: " + ioe.getMessage());
}
// fall back to returning the local data if the remote is unreachable
intlogger.info("Active server unavailable; falling back to local copy.");
}
InputStream is = req.getInputStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- int ch = 0;
- while ((ch = is.read()) >= 0) {
- bos.write(ch);
+ int ch;
+ try {
+ while ((ch = is.read()) >= 0) {
+ bos.write(ch);
+ }
+ } catch (IOException ioe) {
+ intlogger.error("Error: " + ioe.getMessage());
}
RLEBitSet bs = new RLEBitSet(bos.toString()); // The set of records to retrieve
elr.setResult(HttpServletResponse.SC_OK);
try (FileInputStream instream = new FileInputStream(new File(store))) {
ks.load(instream, pass.toCharArray());
} catch (FileNotFoundException fileNotFoundException) {
- System.err.println("ProxyServlet: " + fileNotFoundException);
- fileNotFoundException.printStackTrace();
+ intlogger.error("ProxyServlet: " + fileNotFoundException.getMessage());
} catch (Exception x) {
System.err.println("READING TRUSTSTORE: " + x);
}
try {\r
DB db = new DB();\r
Connection conn = db.getConnection();\r
- try(Statement stmt = conn.createStatement()) {\r
- try(ResultSet rs = stmt.executeQuery("select COUNT(*) from FEEDS where FEEDID = " + id)) {\r
+ try(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {\r
+ stmt.setInt(1, id);\r
+ try(ResultSet rs = stmt.executeQuery()) {\r
if (rs.next()) {\r
count = rs.getInt(1);\r
}\r
}\r
\r
public static Collection<String> getGroupsByClassfication(String classfication) {\r
- List<String> list = new ArrayList<String>();\r
- String sql = "select * from GROUPS where classification = '" + classfication + "'";\r
+ List<String> list = new ArrayList<>();\r
+ String sql = "select * from GROUPS where classification = ?";\r
try {\r
DB db = new DB();\r
@SuppressWarnings("resource")\r
Connection conn = db.getConnection();\r
- try(Statement stmt = conn.createStatement()) {\r
- try(ResultSet rs = stmt.executeQuery(sql)) {\r
+ try(PreparedStatement stmt = conn.prepareStatement(sql)) {\r
+ stmt.setString(1, classfication);\r
+ try(ResultSet rs = stmt.executeQuery()) {\r
while (rs.next()) {\r
int groupid = rs.getInt("groupid");\r
\r
DB db = new DB();\r
@SuppressWarnings("resource")\r
Connection conn = db.getConnection();\r
- try(Statement stmt = conn.createStatement()) {\r
- String sql = "select KEYNAME, VALUE from PARAMETERS where KEYNAME = '" + k + "'";\r
- try(ResultSet rs = stmt.executeQuery(sql)) {\r
+ try(PreparedStatement stmt = conn.prepareStatement("select KEYNAME, VALUE from PARAMETERS where KEYNAME = ?")) {\r
+ stmt.setString(1, k);\r
+ try(ResultSet rs = stmt.executeQuery()) {\r
if (rs.next()) {\r
v = new Parameters(rs);\r
}\r
import java.io.IOException;
import java.util.Properties;
+import org.apache.log4j.Logger;
+
public class SubscriberProps {
private static SubscriberProps instance = null;
+ private static Logger subLogger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.internal");
private Properties properties;
private SubscriberProps(String propsPath) throws IOException{
try {
instance = new SubscriberProps(propsPath);
} catch (IOException ioe) {
- ioe.printStackTrace();
+ subLogger.error("IO Exception: " + ioe.getMessage());
}
}
return instance;