Skip to content
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 @@ -32,17 +32,13 @@ public class ExtensionUtil {
public String getURLContents(String address) {
StringBuilder builder = new StringBuilder();

try {
URL url = new URL(address);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
try (BufferedReader in = new BufferedReader(new InputStreamReader(new URL(address).openStream()))) {
String str = null;

while ((str = in.readLine()) != null) {
builder.append(str);
builder.append("\r\n");
}

in.close();
} catch (Exception e) {
// could not load page contents
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public void viewAttachments(String channelId, Long messageId, String attachmentI
File temp = File.createTempFile(attachment.getId(), ".pdf");
temp.deleteOnExit();

OutputStream out = new FileOutputStream(temp);
IOUtils.copy(in, out);
out.close();
try (OutputStream out = new FileOutputStream(temp)) {
IOUtils.copy(in, out);
}

new MirthPDFViewer(true, temp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import javax.sql.DataSource;

import org.apache.commons.dbutils.DbUtils;

public class DisabledConnectionPool implements ConnectionPool {
private String url;
private String username;
Expand All @@ -31,9 +33,14 @@ public DisabledConnectionPool(String url, String username, String password, bool
@Override
public PooledConnection getConnection() throws SQLException {
Connection connection = DriverManager.getConnection(url, username, password);
connection.setAutoCommit(false);
if (readOnly) {
connection.setReadOnly(true);
try {
connection.setAutoCommit(false);
if (readOnly) {
connection.setReadOnly(true);
}
} catch (Exception e) {
DbUtils.closeQuietly(connection);
throw e;
}
return new PooledConnection(connection, connection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ public static Socket createSocket(TcpConfiguration configuration, String localAd
Socket socket = configuration.createSocket();

if (StringUtils.isNotEmpty(localAddr)) {
InetAddress localAddress = InetAddress.getByName(TcpUtil.getFixedHost(localAddr));
socket.bind(new InetSocketAddress(localAddress, localPort));
try {
InetAddress localAddress = InetAddress.getByName(TcpUtil.getFixedHost(localAddr));
socket.bind(new InetSocketAddress(localAddress, localPort));
} catch (Exception e) {
socket.close();
throw e;
}
}

return socket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,10 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
((GZIPOutputStream) responseOutputStream).finish();
}
} catch (Throwable t) {
IOUtils.closeQuietly(fis);
response.reset();
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
} finally {
IOUtils.closeQuietly(fis);
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -394,8 +395,8 @@ private boolean isCancelled() {

private void executeUpdate(String sql) throws SQLException {
SqlSession session = SqlConfig.getInstance().getSqlSessionManager().openSession();
try {
session.getConnection().createStatement().executeUpdate(sql);
try (Statement statement = session.getConnection().createStatement()) {
statement.executeUpdate(sql);
} finally {
session.close();
}
Expand Down
13 changes: 9 additions & 4 deletions server/src/main/java/net/lingala/zip4j/unzip/UnzipEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,15 @@ private RandomAccessFile checkSplitFile() throws ZipException {
RandomAccessFile raf = new RandomAccessFile(partFile, InternalZipConstants.READ_MODE);

if (currSplitFileCounter == 1) {
byte[] splitSig = new byte[4];
raf.read(splitSig);
if (Raw.readIntLittleEndian(splitSig, 0) != InternalZipConstants.SPLITSIG) {
throw new ZipException("invalid first part split file signature");
try {
byte[] splitSig = new byte[4];
raf.read(splitSig);
if (Raw.readIntLittleEndian(splitSig, 0) != InternalZipConstants.SPLITSIG) {
throw new ZipException("invalid first part split file signature");
}
} catch (Exception e) {
raf.close();
throw e;
}
}
return raf;
Expand Down
Loading