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 @@ -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 @@ -815,7 +815,6 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
response.setStatus(HttpStatus.SC_OK);

if (baseRequest.getMethod().equalsIgnoreCase(HttpMethod.GET.asString())) {
FileInputStream fis = null;
try {
response.setContentType(contentType);
response.addHeader("Content-Disposition", "attachment; filename=" + file.getName());
Expand All @@ -831,15 +830,15 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}
}

fis = new FileInputStream(file);
IOUtils.copy(fis, responseOutputStream);
try (FileInputStream fis = new FileInputStream(file)) {
IOUtils.copy(fis, responseOutputStream);
}

// If we gzipped, we need to finish the stream now
if (responseOutputStream instanceof GZIPOutputStream) {
((GZIPOutputStream) responseOutputStream).finish();
}
} catch (Throwable t) {
IOUtils.closeQuietly(fis);
response.reset();
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
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.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -392,11 +393,9 @@ private boolean isCancelled() {
}

private void executeUpdate(String sql) throws SQLException {
SqlSession session = SqlConfig.getInstance().getSqlSessionManager().openSession();
try {
session.getConnection().createStatement().executeUpdate(sql);
} finally {
session.close();
try (SqlSession session = SqlConfig.getInstance().getSqlSessionManager().openSession();
Statement statement = session.getConnection().createStatement()) {
statement.executeUpdate(sql);
Comment thread
tonygermano marked this conversation as resolved.
Resolved
}
}

Expand Down
Loading