Skip to content
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

CXF-9107 Clean up coverity resource leaks and a javascript method typo #2253

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,22 @@ private static String[] getFilterList(ClassLoader parent, String propFile) throw
}

private static Properties getProperties(ClassLoader parent, String propsFileName) throws IOException {
InputStream in = parent.getResourceAsStream(propsFileName);
Properties props = new Properties();

if (null == in) {
in = PlugInClassLoader.class.getResourceAsStream(propsFileName);
try (InputStream in = parent.getResourceAsStream(propsFileName)) {
if (null != in) {
props.load(in);
LOG.fine("Contents: " + propsFileName + props);
return props;
}
}

if (null == in) {
try (InputStream in = PlugInClassLoader.class.getResourceAsStream(propsFileName)) {
if (null != in) {
props.load(in);
LOG.fine("Contents: " + propsFileName + props);
return props;
} else {
String msg = "Internal rar classloader failed to locate configuration resource: "
+ propsFileName;
IOException ioe = new IOException(msg);
Expand All @@ -90,13 +100,6 @@ private static Properties getProperties(ClassLoader parent, String propsFileName
throw ioe;
}
}

Properties props = new Properties();

props.load(in);
LOG.fine("Contents: " + propsFileName + props);

return props;
}

private String[] loadUrls(ClassLoader parent) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function org_apache_cxf_pad_string(string, len, pad, type) {
pad = typeof(pad) == 'string' ? pad : ' ';

if (type == org_apache_cxf_pad_string_PAD_BOTH) {
string = org_apache_cxf_pad_sring(Math.floor(len / 2) + string.length,
string = org_apache_cxf_pad_string(Math.floor(len / 2) + string.length,
pad, org_apache_cxf_pad_string_PAD_LEFT);
return (org_apache_cxf_pad_string(Math.ceil(len / 2) + string.length,
pad, org_apache_cxf_pad_string_PAD_RIGHT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public T readFrom(Class<T> type, Type genericType, Annotation[] anns, MediaType
XMLStreamReader reader = null;
String enc = HttpUtils.getEncoding(mt, StandardCharsets.UTF_8.name());
Unmarshaller unmarshaller = null;
try {
InputStream realStream = getInputStream(type, genericType, is);
try (InputStream realStream = getInputStream(type, genericType, is)) {
if (Document.class.isAssignableFrom(type)) {
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
reader = createReader(type, realStream, false, enc);
Expand Down Expand Up @@ -240,7 +239,6 @@ public T readFrom(Class<T> type, Type genericType, Annotation[] anns, MediaType
response = checkAdapter(response, type, anns, false);
}
return type.cast(response);

} catch (JAXBException e) {
handleJAXBException(e, true);
} catch (XMLStreamException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,15 @@ protected void createTables() throws SQLException {
protected void verifyTable(Connection con, String tableName, String[][] tableCols) {
try {
DatabaseMetaData metadata = con.getMetaData();
ResultSet rs = metadata.getColumns(null, null, tableName, "%");

Set<String> dbCols = new HashSet<>();
List<String[]> newCols = new ArrayList<>();
while (rs.next()) {
dbCols.add(rs.getString(4));
try (ResultSet rs = metadata.getColumns(null, null, tableName, "%")) {
while (rs.next()) {
dbCols.add(rs.getString(4));
}
}

for (String[] col : tableCols) {
if (!dbCols.contains(col[0])) {
newCols.add(col);
Expand Down
Loading